rem
stringlengths
0
274k
add
stringlengths
0
169k
context
stringlengths
9
471k
if (strcmp (domainlist[i].domain, domain) == 0)
pthread_rdwr_runlock_np (&domainlock); return; } again: ++count; 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)); } 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)); } else { pthread_rdwr_runlock_np (&domainlock); if (count > 2) return; if (pthread_mutex_trylock (&search_lock) == 0)
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 not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
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; } pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); }
if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]);
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 not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
++i;
else { if (debug_flag) log_msg (LOG_DEBUG, "trylock = failed"); pthread_mutex_lock (&search_lock); } pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); goto again;
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 not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
transformation_hint);
labels_transformation);
finish_constraint_and_action(void){ unsigned int i; float cost; int have_constraint = (pattern[patno].autohelper_flag & HAVE_CONSTRAINT); int have_action = (pattern[patno].autohelper_flag & HAVE_ACTION); int no_labels = 1; /* Mark that this pattern has an autohelper. */ pattern[patno].autohelper = dummyhelper; /* Generate autohelper function declaration. */ code_pos += sprintf(code_pos, "static int\nautohelper%s%d(int trans, int move, int color, int action)\n{\n int", prefix, patno); /* Generate variable declarations. */ for (i = 0; i < sizeof(VALID_CONSTRAINT_LABELS); i++) { int c = (int) VALID_CONSTRAINT_LABELS[i]; if (label_coords[c][0] != -1) code_pos += sprintf(code_pos, " %c,", c); } /* Replace the last ',' with ';' */ if (*(code_pos-1) == ',') *(code_pos-1) = ';'; else { code_pos -= 3; /* no variable, erase "int" */ code_pos += sprintf(code_pos, "UNUSED(trans);"); } /* Include UNUSED statements for two parameters */ code_pos += sprintf(code_pos, "\n UNUSED(color);\n"); if (!have_constraint || !have_action) code_pos += sprintf(code_pos, " UNUSED(action);\n"); /* Generate coordinate transformations. */ for (i = 0; i < sizeof(VALID_CONSTRAINT_LABELS); i++) { int c = (int) VALID_CONSTRAINT_LABELS[i]; if (label_coords[c][0] != -1) { int x; int y; TRANSFORM2(label_coords[c][0] - ci - movei, label_coords[c][1] - cj - movej, &x, &y, transformation_hint); code_pos += sprintf(code_pos, "\n %c = AFFINE_TRANSFORM(%d, trans, move);", c, OFFSET(x, y)); no_labels = 0; } } /* move might be unused. Add an UNUSED statement to avoid warnings. */ if (no_labels) code_pos += sprintf(code_pos, "\n UNUSED(move);"); code_pos += sprintf(code_pos, "\n\n"); if (have_constraint && have_action) code_pos += sprintf(code_pos, " if (!action)\n "); if (have_constraint) { code_pos += sprintf(code_pos, " return "); parse_constraint_or_action(constraint, &cost); pattern[patno].constraint_cost = cost; code_pos += sprintf(code_pos, ";\n"); } if (have_action) { code_pos += sprintf(code_pos, " "); parse_constraint_or_action(action, &cost); code_pos += sprintf(code_pos, ";\n"); code_pos += sprintf(code_pos, "\n return 0;\n"); } code_pos += sprintf(code_pos, "}\n\n"); /* Check that we have not overrun our buffer. That would be really bad. */ assert(code_pos <= autohelper_code + sizeof(autohelper_code));}
(*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk); (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);
void setNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct){ if (!NMTVCUSTOMDRAWFc.cached) cacheNMTVCUSTOMDRAWFields(env, lpObject); setNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);#ifndef _WIN32_WCE (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.iLevel, (jint)lpStruct->iLevel);#endif (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk); (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);}
str.sprintf("<A HREF=\"man:/%s(%c,%c)\">%s</A>", h, sec, tolower(subsec), h);
str.sprintf("<A HREF=\"man:/%s(%c%c)\">%s</A>", h, sec, tolower(subsec), h);
static void add_links(char *c){ /* ** Add the links to the output. ** At the moment the following are recognized: ** ** name(*) -> ../man?/name.* ** method://string -> method://string ** www.host.name -> http://www.host.name ** ftp.host.name -> ftp://ftp.host.name ** name@host -> mailto:name@host ** <name.h> -> file:/usr/include/name.h (guess) ** ** Other possible links to add in the future: ** ** /dir/dir/file -> file:/dir/dir/file */ int i,j,nr; char *f, *g,*h; char *idtest[6]; /* url, mailto, www, ftp, manpage */ out_length+=strlen(c); /* search for (section) */ nr=0; idtest[0]=strstr(c+1,"://"); idtest[1]=strchr(c+1,'@'); idtest[2]=strstr(c,"www."); idtest[3]=strstr(c,"ftp."); idtest[4]=strchr(c+1,'('); idtest[5]=strstr(c+1,".h&gt;"); for (i=0; i<6; i++) nr += (idtest[i]!=NULL); while (nr) { j=-1; for (i=0; i<6; i++) if (idtest[i] && (j<0 || idtest[i]<idtest[j])) j=i; switch (j) { case 5: { /* <name.h> */ f=idtest[5]; h=f+2; g=f; while (g>c && g[-1]!=';') g--; bool wrote_include = false; if (g!=c) { QCString dir; QCString file(g, h - g + 1); file = file.stripWhiteSpace(); for (int index = 0; includedirs[index]; index++) { QCString str = QCString(includedirs[index]) + "/" + file; if (!access(str, R_OK)) { dir = includedirs[index]; break; } } if (!dir.isEmpty()) { char t; t=*g; *g=0; output_real(c); *g=t;*h=0; QCString str; str.sprintf("<A HREF=\"file:%s/%s\">%s</A>&gt;", dir.data(), file.data(), file.data()); output_real(str.data()); c=f+6; wrote_include = true; } } if (!wrote_include) { f[5]=0; output_real(c); f[5]=';'; c=f+5; } } break; case 4: /* manpage */ f=idtest[j]; /* check section */ g=strchr(f,')'); if (g && f-g<6 && (isalnum(f[-1]) || f[-1]=='>') && ((isdigit(f[1]) && f[1]!='0' && (f[2]==')' || (isalpha(f[2]) && f[3]==')') || f[2]=='X')) || (f[2]==')' && (f[1]=='n' || f[1]=='l')))) { /* this might be a link */ h=f-1; /* skip html makeup */ while (h>c && *h=='>') { while (h!=c && *h!='<') h--; if (h!=c) h--; } if (isalnum(*h)) { char t,sec,subsec, *e; e=h+1; sec=f[1]; subsec=f[2]; if ((subsec=='X' && f[3]!=')')|| subsec==')') subsec='\0'; while (h>c && (isalnum(h[-1]) || h[-1]=='_' || h[-1]==':' || h[-1]=='-' || h[-1]=='.')) h--; t=*h; *h='\0'; output_real(c); *h=t; t=*e; *e='\0'; QCString str; if (subsec) str.sprintf("<A HREF=\"man:/%s(%c,%c)\">%s</A>", h, sec, tolower(subsec), h); else str.sprintf("<A HREF=\"man:/%s(%c)\">%s</A>", h, sec, h); output_real(str.data()); *e=t; c=e; } } *f='\0'; output_real(c); *f='('; idtest[4]=f-1; c=f; break; /* manpage */ case 3: /* ftp */ case 2: /* www */ g=f=idtest[j]; while (*g && (isalnum(*g) || *g=='_' || *g=='-' || *g=='+' || *g=='.')) g++; if (g[-1]=='.') g--; if (g-f>4) { char t; t=*f; *f='\0'; output_real(c); *f=t; t=*g;*g='\0'; QCString str; str.sprintf("<A HREF=\"%s://%s\">%s</A>", ((j==3)?"ftp":"http"), f, f); output_real(str.data()); *g=t; c=g; } else { f[3]='\0'; output_real(c); c=f+3; f[3]='.'; } break; case 1: /* mailto */ g=f=idtest[1]; while (g>c && (isalnum(g[-1]) || g[-1]=='_' || g[-1]=='-' || g[-1]=='+' || g[-1]=='.' || g[-1]=='%')) g--; h=f+1; while (*h && (isalnum(*h) || *h=='_' || *h=='-' || *h=='+' || *h=='.')) h++; if (*h=='.') h--; if (h-f>4 && f-g>1) { char t; t=*g; *g='\0'; output_real(c); *g=t;t=*h;*h='\0'; QCString str; str.sprintf("<A HREF=\"mailto:%s\">%s</A>", g, g); output_real(str.data()); *h=t; c=h; } else { *f='\0'; output_real(c); *f='@'; idtest[1]=c; c=f; } break; case 0: /* url */ g=f=idtest[0]; while (g>c && isalpha(g[-1]) && islower(g[-1])) g--; h=f+3; while (*h && !isspace(*h) && *h!='<' && *h!='>' && *h!='"' && *h!='&') h++; if (f-g>2 && f-g<7 && h-f>3) { char t; t=*g; *g='\0'; output_real(c); *g=t; t=*h; *h='\0'; QCString str; str.sprintf("<A HREF=\"%s\">%s</A>", g, g); output_real(str.data()); *h=t; c=h; } else { f[1]='\0'; output_real(c); f[1]='/'; c=f+1; } break; default: break; } nr=0; if (idtest[0] && idtest[0]<c) idtest[0]=strstr(c+1,"://"); if (idtest[1] && idtest[1]<c) idtest[1]=strchr(c+1,'@'); if (idtest[2] && idtest[2]<c) idtest[2]=strstr(c,"www."); if (idtest[3] && idtest[3]<c) idtest[3]=strstr(c,"ftp."); if (idtest[4] && idtest[4]<c) idtest[4]=strchr(c+1,'('); if (idtest[5] && idtest[5]<c) idtest[5]=strstr(c+1,".h&gt;"); for (i=0; i<6; i++) nr += (idtest[i]!=NULL); } output_real(c);}
kdDebug() << "Full path given to kcmshell - not supported yet" << endl;
kdDebug(1208) << "Full path given to kcmshell - not supported yet" << endl;
static QString locateModule(const QCString module){ // locate the desktop file //QStringList files; if (module[0] == '/') { kdDebug() << "Full path given to kcmshell - not supported yet" << endl; // (because of KService::findServiceByDesktopPath) //files.append(args->arg(0)); } QString path = KCGlobal::baseGroup(); path += module; path += ".desktop"; if (!KService::serviceByDesktopPath( path )) { // Path didn't work. Trying as a name KService::Ptr serv = KService::serviceByDesktopName( module ); if ( serv ) path = serv->entryPath(); else { kdError(1208) << i18n("Module %1 not found!").arg(module) << endl; return QString::null; } } return path;}
( void )KGlobal::locale()->charset();
int kdemain( int argc, char **argv ) { KInstance instance( "kio_help" ); ( void )KGlobal::locale()->charset(); fillInstance(instance); (void)instance.config(); // we need this one to make sure system globals are read kdDebug(7101) << "Starting " << getpid() << endl; if (argc != 4) { fprintf(stderr, "Usage: kio_help protocol domain-socket1 domain-socket2\n"); exit(-1); } LIBXML_TEST_VERSION xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; xmlSetExternalEntityLoader(meinExternalEntityLoader); HelpProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); kdDebug(7101) << "Done" << endl; return 0; }
signal(SIGINT,&destruct); signal(SIGQUIT,&destruct); signal(SIGILL,&destruct); signal(SIGTRAP,&destruct); signal(SIGABRT,&destruct); signal(SIGBUS,&destruct); signal(SIGSEGV,&destruct); signal(SIGUSR2,&destruct); signal(SIGPIPE,&destruct); signal(SIGALRM,&destruct); signal(SIGTERM,&destruct); signal(SIGFPE,&destruct); #ifdef SIGPOLL signal(SIGPOLL, &destruct); #endif #ifdef SIGSYS signal(SIGSYS, &destruct); #endif #ifdef SIGVTALRM signal(SIGVTALRM, &destruct); #endif #ifdef SIGXCPU signal(SIGXCPU, &destruct); #endif #ifdef SIGXFSZ signal(SIGXFSZ, &destruct); #endif SmbProtocol *slave=new SmbProtocol(argv[2], argv[3]); globalSlave=slave; slave->dispatchLoop();
SmbProtocol slave(argv[2], argv[3]); slave.dispatchLoop();
int kdemain( int argc, char **argv ){ KLocale::setMainCatalogue("kio_smbro"); KInstance instance( "kio_smb" ); if (argc != 4) { fprintf(stderr, "Usage: kio_smb protocol domain-socket1 domain-socket2\n"); exit(-1); } //kdDebug(7101) << "Smb: kdemain: starting" << endl; signal(SIGINT,&destruct); signal(SIGQUIT,&destruct); signal(SIGILL,&destruct); signal(SIGTRAP,&destruct); signal(SIGABRT,&destruct); signal(SIGBUS,&destruct); signal(SIGSEGV,&destruct); signal(SIGUSR2,&destruct); signal(SIGPIPE,&destruct); signal(SIGALRM,&destruct); signal(SIGTERM,&destruct); signal(SIGFPE,&destruct);#ifdef SIGPOLL signal(SIGPOLL, &destruct);#endif#ifdef SIGSYS signal(SIGSYS, &destruct);#endif#ifdef SIGVTALRM signal(SIGVTALRM, &destruct);#endif#ifdef SIGXCPU signal(SIGXCPU, &destruct);#endif#ifdef SIGXFSZ signal(SIGXFSZ, &destruct);#endif SmbProtocol *slave=new SmbProtocol(argv[2], argv[3]); globalSlave=slave; slave->dispatchLoop(); return 0;}
if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0); if (arg11) setCREATESTRUCTFields(env, arg11, lparg11);
JNIEXPORT jint JNICALL OS_NATIVE(CreateWindowExW) (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jobject arg11){ jchar *lparg1=NULL; jchar *lparg2=NULL; CREATESTRUCT _arg11, *lparg11=NULL; jint rc; NATIVE_ENTER(env, that, "CreateWindowExW\n") if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL); if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL); if (arg11) lparg11 = getCREATESTRUCTFields(env, arg11, &_arg11); rc = (jint)CreateWindowExW(arg0, (LPWSTR)lparg1, (LPWSTR)lparg2, arg3, arg4, arg5, arg6, arg7, (HWND)arg8, (HMENU)arg9, (HINSTANCE)arg10, lparg11); if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0); if (arg11) setCREATESTRUCTFields(env, arg11, lparg11); NATIVE_EXIT(env, that, "CreateWindowExW\n") return rc;}
DEBUG_CHECK_NULL(env, arg0)
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__I_3SI (JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jint arg2){ jshort *lparg1=NULL; DEBUG_CALL("MoveMemory\n") if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2); if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0);}
if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
if (arg3) lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL);
JNIEXPORT jint JNICALL OS_NATIVE(SetDIBColorTable) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3){ jbyte *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "SetDIBColorTable\n") if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL); rc = (jint)SetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3); if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT); NATIVE_EXIT(env, that, "SetDIBColorTable\n") return rc;}
if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT);
if (arg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, JNI_ABORT);
JNIEXPORT jint JNICALL OS_NATIVE(SetDIBColorTable) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3){ jbyte *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "SetDIBColorTable\n") if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL); rc = (jint)SetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3); if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT); NATIVE_EXIT(env, that, "SetDIBColorTable\n") return rc;}
kdError() << "Usage: kio_thumbnail protocol domain-socket1 domain-socket2" << endl;
kdError(7115) << "Usage: kio_thumbnail protocol domain-socket1 domain-socket2" << endl;
int kdemain(int argc, char **argv){ nice( 5 ); // creating KApplication in a slave in not a very good idea, // as dispatchLoop() doesn't allow it to process its messages, // so it for example wouldn't reply to ksmserver - on the other // hand, this slave uses QPixmaps for some reason, and they // need QApplication // and HTML previews need even KApplication :( putenv(strdup("SESSION_MANAGER=")); KApplication::disableAutoDcopRegistration(); KApplication app(argc, argv, "kio_thumbnail", false, true); if (argc != 4) { kdError() << "Usage: kio_thumbnail protocol domain-socket1 domain-socket2" << endl; exit(-1); } ThumbnailProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0;}
prop = xmlGetNsProp(inst, (const xmlChar *)"terminate", XSLT_NAMESPACE);
prop = xsltGetNsProp(inst, (const xmlChar *)"terminate", XSLT_NAMESPACE);
xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst) { xmlChar *prop, *message; int terminate = 0; if ((ctxt == NULL) || (inst == NULL)) return; prop = xmlGetNsProp(inst, (const xmlChar *)"terminate", XSLT_NAMESPACE); if (prop != NULL) { if (xmlStrEqual(prop, (const xmlChar *)"yes")) { terminate = 1; } else if (xmlStrEqual(prop, (const xmlChar *)"yes")) { terminate = 0; } else { xsltGenericError(xsltGenericErrorContext, "xsl:message : terminate expecting 'yes' or 'no'\n"); } xmlFree(prop); } message = xsltEvalTemplateString(ctxt, node, inst); if (message != NULL) { int len = xmlStrlen(message); xsltGenericError(xsltGenericErrorContext, (const char *)message); if ((len > 0) && (message[len - 1] != '\n')) xsltGenericError(xsltGenericErrorContext, "\n"); xmlFree(message); } if (terminate) ctxt->state = XSLT_STATE_STOPPED;}
&& dragon[pos].owl_defense_point != NO_MOVE)
&& dragon[pos].owl_defense_point != NO_MOVE) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
&& is_legal(dragon[pos].owl_second_defense_point, color))
&& is_legal(dragon[pos].owl_second_defense_point, color)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
&& dragon[pos].owl_attack_point != NO_MOVE)
&& dragon[pos].owl_attack_point != NO_MOVE) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
if (dragon[pos].owl_attack_point != NO_MOVE)
if (dragon[pos].owl_attack_point != NO_MOVE) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
&& is_legal(dragon[pos].owl_second_attack_point, color))
&& is_legal(dragon[pos].owl_second_attack_point, color)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
&& ON_BOARD(dragon[pos].owl_defense_point))
&& ON_BOARD(dragon[pos].owl_defense_point)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
&& ON_BOARD(dragon[pos].owl_attack_point))
&& ON_BOARD(dragon[pos].owl_attack_point)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
DEBUG(DEBUG_OWL, "owl: %1m might defend the uncertain dragon at %1m at move %d\n", dragon[pos].owl_attack_point, pos, movenum+1); }
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
lpStruct->dwSize = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize);
INITCOMMONCONTROLSEX *getINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct){ if (!INITCOMMONCONTROLSEXFc.cached) cacheINITCOMMONCONTROLSEXFields(env, lpObject); lpStruct->dwICC = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwICC); lpStruct->dwSize = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize); return lpStruct;}
QByteArray fn;
QCString fn;
QDataStream& operator>> (QDataStream& s, sftpFileAttr& fa) { // XXX set all member variable to defaults // XXX Add some error checking in here in case // we get a bad sftp packet. fa.clear(); if( fa.mDirAttrs ) { QByteArray fn; s >> fn; KRemoteEncoding encoder ( fa.mEncoding.data() ); fa.mFilename = encoder.decode( QCString(fn.data(), fn.size()+1) ); s >> fa.mLongname; fa.mLongname.truncate( fa.mLongname.size() ); //kdDebug() << ">>: ftpfileattr long filename (" << fa.mLongname.size() << ")= " << fa.mLongname << endl; } s >> fa.mFlags; // get flags if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) { Q_ULLONG fileSize; s >> fileSize; fa.setFileSize(fileSize); } Q_UINT32 x; if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) { s >> x; fa.setUid(x); s >> x; fa.setGid(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) { s >> x; fa.setPermissions(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) { s >> x; fa.setAtime(x); s >> x; fa.setMtime(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_EXTENDED ) { s >> x; fa.setExtendedCount(x); // XXX: Read in extensions from data stream here // s.readBytes(extendedtype).readBytes(extendeddata); } fa.getUserGroupNames(); return s;}
KRemoteEncoding encoder ( fa.mEncoding.data() ); fa.mFilename = encoder.decode( QCString(fn.data(), fn.size()+1) );
KRemoteEncoding encoder ( encoding.data() ); fa.mFilename = encoder.decode( fn );
QDataStream& operator>> (QDataStream& s, sftpFileAttr& fa) { // XXX set all member variable to defaults // XXX Add some error checking in here in case // we get a bad sftp packet. fa.clear(); if( fa.mDirAttrs ) { QByteArray fn; s >> fn; KRemoteEncoding encoder ( fa.mEncoding.data() ); fa.mFilename = encoder.decode( QCString(fn.data(), fn.size()+1) ); s >> fa.mLongname; fa.mLongname.truncate( fa.mLongname.size() ); //kdDebug() << ">>: ftpfileattr long filename (" << fa.mLongname.size() << ")= " << fa.mLongname << endl; } s >> fa.mFlags; // get flags if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) { Q_ULLONG fileSize; s >> fileSize; fa.setFileSize(fileSize); } Q_UINT32 x; if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) { s >> x; fa.setUid(x); s >> x; fa.setGid(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) { s >> x; fa.setPermissions(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) { s >> x; fa.setAtime(x); s >> x; fa.setMtime(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_EXTENDED ) { s >> x; fa.setExtendedCount(x); // XXX: Read in extensions from data stream here // s.readBytes(extendedtype).readBytes(extendeddata); } fa.getUserGroupNames(); return s;}
expr = xmlGetNsProp(node, name, ns);
expr = xsltGetNsProp(node, name, ns);
xsltEvalStaticAttrValueTemplate(xsltStylesheetPtr style, xmlNodePtr node, const xmlChar *name, const xmlChar *ns, int *found) { const xmlChar *ret; xmlChar *expr; if ((style == NULL) || (node == NULL) || (name == NULL)) return(NULL); expr = xmlGetNsProp(node, name, ns); if (expr == NULL) { *found = 0; return(NULL); } *found = 1; ret = xmlStrchr(expr, '{'); if (ret != NULL) { xmlFree(expr); return(NULL); } return(expr);}
const QString & getContinuation ()
const QByteArray & getContinuation ()
const QString & getContinuation () { return continuation; };
qInstallMsgHandler(msgHandler);
KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program under a different uid."), KAboutData::Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http: aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]");
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
QString command, file; bool keep = true; bool terminal = false;
KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
KStartParams parm(argc, argv); QString s; uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp);
if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) kDebugFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); exit(0); } kDebugFatal("Could not stop daemon");
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0;
QCString user = args->getOption("u"); struct passwd *pw = getpwnam(user); if (pw == 0L) { kDebugFatal("User %s does not exist", (const char *) user); exit(1); } uid_t uid = pw->pw_uid; bool change_uid = (getuid() != uid); if (args->count() == 0) KCmdLineArgs::usage(i18n("No command specified!")); QCString command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i);
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } bool change_uid = (getuid() != uid);
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
if (change_uid && !file.isEmpty()) {
QString file = QFile::decodeName(args->getOption("f")); if (!file.isEmpty()) {
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
if (!fi.exists()) qFatal("File does not exist: %s", file.latin1());
if (!fi.exists()) { kDebugFatal("File does not exist: %s", file.latin1()); exit(1); }
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno));
if (setrlimit(RLIMIT_CORE, &rlim)) { kDebugFatal("rlimit(): %s", strerror(errno)); exit(1); }
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
KApplication *app = new KApplication(argc, argv, "kdesu");
KApplication *app = new KApplication;
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user,
KDEsuDialog *dlg = new KDEsuDialog(command, user,
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
pwDlg->setEchoMode(echo_mode); pwDlg->exec();
dlg->setEchoMode(echo_mode); dlg->exec();
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass());
switch (dlg->result()) { case KDEsuDialog::Accepted: strcpy(pass, dlg->getPass());
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
case KPasswordDlg::Rejected:
case KDEsuDialog::Rejected:
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
case KPasswordDlg::AsUser:
case KDEsuDialog::AsUser:
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
keep = pwDlg->keepPass(); delete pwDlg;
keep = dlg->keepPass(); delete dlg;
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
kdDebug(7101)<<"exiting normally"<<endl;
int kdemain( int argc, char **argv ){ KLocale::setMainCatalogue("kio_smbro"); KInstance instance( "kio_smb" ); if (argc != 4) { fprintf(stderr, "Usage: kio_smb protocol domain-socket1 domain-socket2\n"); exit(-1); } //kdDebug(7101) << "Smb: kdemain: starting" << endl; SmbProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0;}
std::cout << myFileFilters << std::endl;
static void buildSupportedVectorFileFilter_(QString & fileFilters){ static QString myFileFilters = ""; // if we've already built the supported vector string, just return what // we've already built if ( ! myFileFilters.isEmpty() ) { fileFilters = myFileFilters; return; } // first get the GDAL driver manager OGRSFDriverRegistrar *driverRegistrar = OGRSFDriverRegistrar::GetRegistrar(); if (!driverRegistrar) { QMessageBox::warning(0,"OGR Driver Manger","unable to get OGRDriverManager"); return; // XXX good place to throw exception if we } // XXX decide to do exceptions // then iterate through all of the supported drivers, adding the // corresponding file filter OGRSFDriver *driver; // current driver QString driverName; // current driver name // Grind through all the drivers and their respective metadata. // We'll add a file filter for those drivers that have a file // extension defined for them; the others, welll, even though // theoreticaly we can open those files because there exists a // driver for them, the user will have to use the "All Files" to // open datasets with no explicitly defined file name extension.#ifdef QGISDEBUG std::cerr << "Driver count: " << driverRegistrar->GetDriverCount() << std::endl;#endif for (int i = 0; i < driverRegistrar->GetDriverCount(); ++i) { driver = driverRegistrar->GetDriver(i); Q_CHECK_PTR(driver); if (!driver) { qWarning("unable to get driver %d", i); continue; } driverName = driver->GetName(); if (driverName.startsWith("ESRI")) { myFileFilters += createFileFilter_("ESRI Shapefiles", "*.shp"); } else if (driverName.startsWith("UK")) { // XXX needs file filter extension } else if (driverName.startsWith("SDTS")) { myFileFilters += createFileFilter_( "Spatial Data Transfer Standard", "*catd.ddf" ); } else if (driverName.startsWith("TIGER")) { // XXX needs file filter extension } else if (driverName.startsWith("S57")) { // XXX needs file filter extension } else if (driverName.startsWith("MapInfo")) { myFileFilters += createFileFilter_("MapInfo", "*.mif *.tab"); // XXX needs file filter extension } else if (driverName.startsWith("DGN")) { // XXX needs file filter extension } else if (driverName.startsWith("VRT")) { // XXX needs file filter extension } else if (driverName.startsWith("AVCBin")) { // XXX needs file filter extension } else if (driverName.startsWith("REC")) { // XXX needs file filter extension } else if (driverName.startsWith("Memory")) { // XXX needs file filter extension } else if (driverName.startsWith("Jis")) { // XXX needs file filter extension } else if (driverName.startsWith("GML")) { // XXX not yet supported; post 0.1 release task // myFileFilters += createFileFilter_( "Geography Markup Language", // "*.gml" ); } else { // NOP, we don't know anything about the current driver // with regards to a proper file filter string } std::cout << myFileFilters << std::endl; } // each loaded GDAL driver // can't forget the default case myFileFilters += "All files (*.*)"; fileFilters = myFileFilters;} // buildSupportedVectorFileFilter_()
std::cout << myFileFilters << std::endl;
static void buildSupportedVectorFileFilter_(QString & fileFilters){ static QString myFileFilters = ""; // if we've already built the supported vector string, just return what // we've already built if ( ! myFileFilters.isEmpty() ) { fileFilters = myFileFilters; return; } // first get the GDAL driver manager OGRSFDriverRegistrar *driverRegistrar = OGRSFDriverRegistrar::GetRegistrar(); if (!driverRegistrar) { QMessageBox::warning(0,"OGR Driver Manger","unable to get OGRDriverManager"); return; // XXX good place to throw exception if we } // XXX decide to do exceptions // then iterate through all of the supported drivers, adding the // corresponding file filter OGRSFDriver *driver; // current driver QString driverName; // current driver name // Grind through all the drivers and their respective metadata. // We'll add a file filter for those drivers that have a file // extension defined for them; the others, welll, even though // theoreticaly we can open those files because there exists a // driver for them, the user will have to use the "All Files" to // open datasets with no explicitly defined file name extension.#ifdef QGISDEBUG std::cerr << "Driver count: " << driverRegistrar->GetDriverCount() << std::endl;#endif for (int i = 0; i < driverRegistrar->GetDriverCount(); ++i) { driver = driverRegistrar->GetDriver(i); Q_CHECK_PTR(driver); if (!driver) { qWarning("unable to get driver %d", i); continue; } driverName = driver->GetName(); if (driverName.startsWith("ESRI")) { myFileFilters += createFileFilter_("ESRI Shapefiles", "*.shp"); } else if (driverName.startsWith("UK")) { // XXX needs file filter extension } else if (driverName.startsWith("SDTS")) { myFileFilters += createFileFilter_( "Spatial Data Transfer Standard", "*catd.ddf" ); } else if (driverName.startsWith("TIGER")) { // XXX needs file filter extension } else if (driverName.startsWith("S57")) { // XXX needs file filter extension } else if (driverName.startsWith("MapInfo")) { myFileFilters += createFileFilter_("MapInfo", "*.mif *.tab"); // XXX needs file filter extension } else if (driverName.startsWith("DGN")) { // XXX needs file filter extension } else if (driverName.startsWith("VRT")) { // XXX needs file filter extension } else if (driverName.startsWith("AVCBin")) { // XXX needs file filter extension } else if (driverName.startsWith("REC")) { // XXX needs file filter extension } else if (driverName.startsWith("Memory")) { // XXX needs file filter extension } else if (driverName.startsWith("Jis")) { // XXX needs file filter extension } else if (driverName.startsWith("GML")) { // XXX not yet supported; post 0.1 release task // myFileFilters += createFileFilter_( "Geography Markup Language", // "*.gml" ); } else { // NOP, we don't know anything about the current driver // with regards to a proper file filter string } std::cout << myFileFilters << std::endl; } // each loaded GDAL driver // can't forget the default case myFileFilters += "All files (*.*)"; fileFilters = myFileFilters;} // buildSupportedVectorFileFilter_()
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type);
void decode_state(bufferlist& bl, int& off) { bl.copy(off, sizeof(type), (char*)&type);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
r.copy(off, sizeof(state), (char*)&state);
bl.copy(off, sizeof(state), (char*)&state);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
r.copy(off, sizeof(mode), (char*)&mode);
bl.copy(off, sizeof(mode), (char*)&mode);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
r.copy(off, sizeof(nread), (char*)&nread);
bl.copy(off, sizeof(nread), (char*)&nread);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
r.copy(off, sizeof(nwrite), (char*)&nwrite);
bl.copy(off, sizeof(nwrite), (char*)&nwrite);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); }
_decode(gather_set, bl, off);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
SysRes res = VG_(do_syscall1)(__NR_pipe, (UWord)fd);
SysRes res = VG_(do_syscall0)(__NR_pipe, (UWord)fd);
Int VG_(pipe) ( Int fd[2] ){ SysRes res = VG_(do_syscall1)(__NR_pipe, (UWord)fd); return res.isError ? -1 : 0;}
for( int i = 0; i < fa.mFilename.size(); i++ ) { kdDebug() << (int)fa.mFilename[i] << endl; }
QDataStream& operator>> (QDataStream& s, sftpFileAttr& fa) { // XXX set all member variable to defaults // XXX Add some error checking in here in case // we get a bad sftp packet. fa.clear(); Q_UINT32 size; if( fa.mDirAttrs ) { s >> fa.mFilename; size = fa.mFilename.size(); fa.mFilename.resize(size+1); fa.mFilename[size] = 0; for( int i = 0; i < fa.mFilename.size(); i++ ) { kdDebug() << (int)fa.mFilename[i] << endl; } s >> fa.mLongname; size = fa.mLongname.size(); fa.mLongname.resize(size+1); fa.mLongname[size] = 0; //kdDebug() << ">> sftpfileattr filename (" << fa.mFilename.size() << ")= " << fa.mFilename << endl; } Q_UINT32 x; s >> fa.mFlags; // get flags if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) { // since we don't have a 64 bit int, ignore the top byte. // Very bad if we get a > 2^32 size s >> x; s >> x; fa.setFileSize(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) { s >> x; fa.setUid(x); s >> x; fa.setGid(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) { s >> x; fa.setPermissions(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) { s >> x; fa.setAtime(x); s >> x; fa.setMtime(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_EXTENDED ) { s >> x; fa.setExtendedCount(x); // XXX: Read in extensions from data stream here // s.readBytes(extendedtype).readBytes(extendeddata); } fa.getUserGroupNames(); return s;}
case 'N':
case 'N': { c++; cstr = scan_number_code( c ); cplusplus = false; break; } #if 0
static char *scan_escape_direct( char *c, QCString& cstr ){ bool exoutputp; bool exskipescape; int i,j; bool cplusplus = true; // Should the c++ be done at the end of the function cstr = ""; intresult=0; switch (*c) { case 'e': cstr = "\\"; curpos++;break; // ### FIXME: it should be the current escape symbol case '0': // ### TODO Where in Unicode? (space of digit width) case '~': // non-breakable-space (resizeable!) case ' ': case '|': // half-non-breakable-space case '^': // quarter-non-breakable-space cstr = "&nbsp;"; curpos++; break; case '"': SKIPEOL; c--; break; // ### TODO \# like \" but does not ignore the end of line (groff(7)) case '$': { c++; cstr = scan_dollar_parameter( c ); cplusplus = false; break; } case 'z': { c++; if (*c=='\\') { c=scan_escape_direct( c+1, cstr ); c--; } else cstr = QCString( c, 1 ); break; } case 'k': c++; if (*c=='(') c+=2; // ### FIXME \k[REG] exists too case '!': case '%': case 'a': case 'd': case 'r': case 'u': case '\n': case '&': cstr = ""; break; case '(': case '[': case 'C': { // Do not go forward as scan_named_character needs the leading symbol cstr = scan_named_character( c ); cplusplus = false; break; } case '*': { c++; cstr = scan_named_string( c ); cplusplus = false; break; } case 'f': { c++; cstr = scan_named_font( c ); cplusplus = false; break; } case 's': // ### FIXME: many forms are missing c++; j=0;i=0; if (*c=='-') {j= -1; c++;} else if (*c=='+') {j=1; c++;} if (*c=='0') c++; else if (*c=='\\') { c++; c=scan_escape_direct( c, cstr ); i=intresult; if (!j) j=1; } else while (isdigit(*c) && (!i || (!j && i<4))) i=i*10+(*c++)-'0'; if (!j) { j=1; if (i) i=i-10; } if (!skip_escape) cstr=change_to_size(i*j); c--; break; case 'n': { c++; intresult = scan_number_register( c ); cplusplus = false; break; } case 'w': c++; i=*c; c++; exoutputp=output_possible; exskipescape=skip_escape; output_possible=false; skip_escape=true; j=0; while (*c!=i) { j++; if ( *c == escapesym ) c = scan_escape_direct( c+1, cstr); else c++; } output_possible=exoutputp; skip_escape=exskipescape; intresult=j; break; case 'l': cstr = "<HR>"; curpos=0; case 'b': case 'v': case 'x': case 'o': case 'L': case 'h': c++; i=*c; c++; exoutputp=output_possible; exskipescape=skip_escape; output_possible=0; skip_escape=true; while (*c != i) if (*c==escapesym) c=scan_escape_direct( c+1, cstr ); else c++; output_possible=exoutputp; skip_escape=exskipescape; break; case 'c': no_newline_output=1; break; case '{': newline_for_fun++; break; // Start conditional block case '}': if (newline_for_fun) newline_for_fun--; break; // End conditional block case 'p': cstr = "<BR>\n";curpos=0; break; case 't': cstr = "\t";curpos=(curpos+8)&0xfff8; break; case '<': cstr = "&lt;";curpos++; break; case '>': cstr = "&gt;";curpos++; break; case '\\': { if (single_escape) c--; else cstr="\\"; break; } case 'N': // ### FIXME should give an Unicode character &#9999; { if (*++c) c++; // c += 2 if (sscanf(c, "%d", &i) != 1) // (### FIXME ugly!) break; QCString temp; temp.sprintf( "%d", i ); // Skip over number (### FIXME ugly!) c += temp.length(); switch(i) { case 8: cstr = "\t"; curpos=(curpos+8)&0xfff8; break; case 34: cstr = "&quot;"; curpos++; break; default: cstr = char( i ); curpos++; break; } break; } case '\'': cstr = "&acute;";curpos++; break; // groff(7) ### TODO verify case '`': cstr = "`";curpos++; break; // groff(7) case '-': cstr = "-";curpos++; break; // groff(7) case '.': cstr = ".";curpos++; break; // groff(7) default: cstr = *c; curpos++; break; } if (cplusplus) c++; return c;}
"rr", "rnn", "aln", "shift", "while", 0 };
"rr", "rnn", "aln", "shift", "while", "do", 0 };
static int get_request(char *req, int len){ static const char *requests[] = { "ab", "di", "ds", "as", "br", "c2", "cc", "ce", "ec", "eo", "ex", "fc", "fi", "ft", "el", "ie", "if", "ig", "nf", "ps", "sp", "so", "ta", "ti", "tm", "B", "I", "Fd", "Fn", "Fo", "Fc", "OP", "Ft", "Fa", "BR", "BI", "IB", "IR", "RB", "RI", "DT", "IP", "TP", "IX", "P", "LP", "PP", "HP", "PD", "Rs", "RS", "Re", "RE", "SB", "SM", "Ss", "SS", "Sh", "SH", "Sx", "TS", "Dt", "TH", "TX", "rm", "rn", "nx", "in", "nr", "am", "de", "Bl", "El", "It", "Bk", "Ek", "Dd", "Os", "Bt", "At", "Fx", "Nx", "Ox", "Bx", "Ux", "Dl", "Bd", "Ed", "Be", "Xr", "Fl", "Pa", "Pf", "Pp", "Dq", "Op", "Oo", "Oc", "Pq", "Ql", "Sq", "Ar", "Ad", "Em", "Va", "Xc", "Nd", "Nm", "Cd", "Cm", "Ic", "Ms", "Or", "Sy", "Dv", "Ev", "Fr", "Li", "No", "Ns", "Tn", "nN", "%A", "%D", "%N", "%O", "%P", "%Q", "%V", "%B", "%J", "%R", "%T", "An", "Aq", "Bq", "Qq", "UR", "UE", "UN", "troff", "nroff", "als", "rr", "rnn", "aln", "shift", "while", 0 }; int r = 0; while (requests[r] && qstrncmp(req, requests[r], len)) r++; return requests[r] ? r : REQ_UNKNOWN;}
const int max_wordlist=100;
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
int j; if (c[1]=='\n') j=1; else j=2;
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
j = nlen;
int j = nlen;
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
out_html(set_font("R"));
out_html(set_font("P"));
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
c[0]='B'; c[1]='I';
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++;
request_mixed_fonts( c, j, "R", "I", false, false );
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
case REQ_do: { *c = '\n'; c++; *c = '.'; break; }
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
QWidget* allocate_kstyle_config(QWidget* parent)
KDE_EXPORT QWidget* allocate_kstyle_config(QWidget* parent)
QWidget* allocate_kstyle_config(QWidget* parent) { return new KeramikStyleConfig(parent); }
cout << (*modules.at(i)).local8Bit(); cout << verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit(); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl;
fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data());
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init(_argc, _argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGlobal::iconLoader()->addAppDir( "kcontrol" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).local8Bit(); cout << verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit(); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() < 1) { args->usage(); return -1; } if (args->count() == 1) { QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
virtual void select(QgsRect *, bool lock)
virtual void select(QgsRect *, bool )
virtual void select(QgsRect *, bool lock) { };
bh->bc->flushing_buffers.insert(bh);
C_Client_FlushFinish(Bufferhead *bh) { this->bh = bh; }
if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
JNIEXPORT jint JNICALL OS_NATIVE(CreateNewWindow) (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jintArray arg3){ Rect _arg2, *lparg2=NULL; jint *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "CreateNewWindow\n") if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); rc = (jint)CreateNewWindow((WindowClass)arg0, (WindowAttributes)arg1, (const Rect *)lparg2, (WindowRef *)lparg3); if (arg2) setRectFields(env, arg2, lparg2); if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); NATIVE_EXIT(env, that, "CreateNewWindow\n") return rc;}
if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
JNIEXPORT jint JNICALL OS_NATIVE(CreateStandardAlert) (JNIEnv *env, jclass that, jshort arg0, jint arg1, jint arg2, jobject arg3, jintArray arg4){ AlertStdCFStringAlertParamRec _arg3, *lparg3=NULL; jint *lparg4=NULL; jint rc; NATIVE_ENTER(env, that, "CreateStandardAlert\n") if (arg3) lparg3 = getAlertStdCFStringAlertParamRecFields(env, arg3, &_arg3); if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); rc = (jint)CreateStandardAlert((AlertType)arg0, (CFStringRef)arg1, (CFStringRef)arg2, (const AlertStdCFStringAlertParamRec *)lparg3, (DialogRef *)lparg4); if (arg3) setAlertStdCFStringAlertParamRecFields(env, arg3, lparg3); if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); NATIVE_EXIT(env, that, "CreateStandardAlert\n") return rc;}
if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
JNIEXPORT jint JNICALL OS_NATIVE(CreateUserPaneControl) (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jintArray arg3){ Rect _arg1, *lparg1=NULL; jint *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "CreateUserPaneControl\n") if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); rc = (jint)CreateUserPaneControl((WindowRef)arg0, lparg1, arg2, (ControlRef *)lparg3); if (arg1) setRectFields(env, arg1, lparg1); if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); NATIVE_EXIT(env, that, "CreateUserPaneControl\n") return rc;}
if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
JNIEXPORT jshort JNICALL OS_NATIVE(FindWindow) (JNIEnv *env, jclass that, jobject arg0, jintArray arg1){ Point _arg0, *lparg0=NULL; jint *lparg1=NULL; jshort rc; NATIVE_ENTER(env, that, "FindWindow\n") if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); rc = (jshort)FindWindow(*(Point *)lparg0, (WindowRef *)lparg1); if (arg0) setPointFields(env, arg0, lparg0); if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); NATIVE_EXIT(env, that, "FindWindow\n") return rc;}
if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0); if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
JNIEXPORT jint JNICALL OS_NATIVE(GetThemeFont) (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jbyteArray arg2, jshortArray arg3, jbyteArray arg4){ jbyte *lparg2=NULL; jshort *lparg3=NULL; jbyte *lparg4=NULL; jint rc; NATIVE_ENTER(env, that, "GetThemeFont\n") if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL); if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL); if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL); rc = (jint)GetThemeFont((ThemeFontID)arg0, (ScriptCode)arg1, (char *)lparg2, (SInt16 *)lparg3, (Style *)lparg4); if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0); if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0); NATIVE_EXIT(env, that, "GetThemeFont\n") return rc;}
if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
JNIEXPORT void JNICALL OS_NATIVE(TXNGetSelection) (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2){ jint *lparg1=NULL; jint *lparg2=NULL; NATIVE_ENTER(env, that, "TXNGetSelection\n") if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); TXNGetSelection((TXNObject)arg0, (TXNOffset *)lparg1, (TXNOffset *)lparg2); if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); NATIVE_EXIT(env, that, "TXNGetSelection\n")}
if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
if (arg0) lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL);
JNIEXPORT void JNICALL OS_NATIVE(memcpy___3BII) (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2){ jbyte *lparg0=NULL; NATIVE_ENTER(env, that, "memcpy___3BII\n") if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); NATIVE_EXIT(env, that, "memcpy___3BII\n")}
if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
if (arg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
JNIEXPORT void JNICALL OS_NATIVE(memcpy___3BII) (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2){ jbyte *lparg0=NULL; NATIVE_ENTER(env, that, "memcpy___3BII\n") if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); NATIVE_EXIT(env, that, "memcpy___3BII\n")}
QString whatToDoText() const { return m_whatToDoText; }
virtual QString whatToDoText() const { return m_whatToDoText; }
QString whatToDoText() const { return m_whatToDoText; }
int pid() const { return m_pid; };
virtual int pid() const { return m_pid; };
int pid() const { return m_pid; };
KDEsuDialog *dlg = new KDEsuDialog(user, auth_user, keep && !terminal); dlg->addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg->addLine(i18n("Priority:"), prio); } int ret = dlg->exec(); if (ret == KDEsuDialog::Rejected) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg;
SuProcess proc; proc.setUser(auth_user); int needpw = proc.checkNeedPassword(); if (needpw < 0) { QString err = i18n("Su returned with an error!\n"); KMessageBox::error(0L, err); exit(1); } if (needpw == 0) { keep = 0; kdDebug() << "Don't need password!!\n"; } QCString password; if (needpw) { KDEsuDialog *dlg = new KDEsuDialog(user, auth_user, keep && !terminal); dlg->addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg->addLine(i18n("Priority:"), prio); } int ret = dlg->exec(); if (ret == KDEsuDialog::Rejected) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg->password(); keep = dlg->keep(); delete dlg; }
int main(int argc, char *argv[]){ KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http://www.stack.nl/~geertj/"); aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication *app = new KApplication; // Stop daemon and exit? if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) { kdError(1206) << "Daemon not running -- nothing to stop\n"; exit(1); } if (client.stopServer() != -1) { kdDebug(1206) << "Daemon stopped\n"; exit(0); } kdError(1206) << "Could not stop daemon\n"; exit(1); } // Get target uid QCString user = args->getOption("u"); QCString auth_user = user; struct passwd *pw = getpwnam(user); if (pw == 0L) { kdError(1206) << "User " << user << " does not exist\n"; exit(1); } bool change_uid = (getuid() != pw->pw_uid); // If file is writeable, do not change uid QString file = QFile::decodeName(args->getOption("f")); if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } change_uid = !fi.isWritable(); } // Get priority/scheduler QCString tmp = args->getOption("p"); bool ok; int priority = tmp.toInt(&ok); if (!ok || (priority < 0) || (priority > 100)) { KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp)); exit(1); } int scheduler = SuProcess::SchedNormal; if (args->isSet("r")) scheduler = SuProcess::SchedRealtime; if ((priority > 50) || (scheduler != SuProcess::SchedNormal)) { change_uid = true; auth_user = "root"; } // Get command if (args->isSet("c")) { command = args->getOption("c"); for (int i=0; i<args->count(); i++) { command += " "; command += args->arg(i); } } else { if( args->count() == 0 ) { KCmdLineArgs::usage(i18n("No command specified!")); exit(1); } command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i); }}// CJM - Test lines remove when working// kdWarning(1206) << args->count();// kdWarning(1206) << command; // Don't change uid if we're don't need to. if (!change_uid) return system(command); // Check for daemon and start if necessary bool just_started = false; bool have_daemon = true; KDEsuClient client; if (!client.isServerSGID()) { kdWarning(1206) << "Daemon not safe (not sgid), not using it.\n"; have_daemon = false; } else if (client.ping() == -1) { if (client.startServer() == -1) { kdWarning(1206) << "Could not start daemon, reduced functionality.\n"; have_daemon = false; } just_started = true; } // Try to exec the command with kdesud. bool keep = !args->isSet("n") && have_daemon; bool terminal = args->isSet("t"); if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user) != -1) return 0; } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); // Start the dialog KDEsuDialog *dlg = new KDEsuDialog(user, auth_user, keep && !terminal); dlg->addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg->addLine(i18n("Priority:"), prio); } int ret = dlg->exec(); if (ret == KDEsuDialog::Rejected) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg; // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (k && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
if (k && have_daemon)
if (keep && have_daemon)
int main(int argc, char *argv[]){ KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http://www.stack.nl/~geertj/"); aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication *app = new KApplication; // Stop daemon and exit? if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) { kdError(1206) << "Daemon not running -- nothing to stop\n"; exit(1); } if (client.stopServer() != -1) { kdDebug(1206) << "Daemon stopped\n"; exit(0); } kdError(1206) << "Could not stop daemon\n"; exit(1); } // Get target uid QCString user = args->getOption("u"); QCString auth_user = user; struct passwd *pw = getpwnam(user); if (pw == 0L) { kdError(1206) << "User " << user << " does not exist\n"; exit(1); } bool change_uid = (getuid() != pw->pw_uid); // If file is writeable, do not change uid QString file = QFile::decodeName(args->getOption("f")); if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } change_uid = !fi.isWritable(); } // Get priority/scheduler QCString tmp = args->getOption("p"); bool ok; int priority = tmp.toInt(&ok); if (!ok || (priority < 0) || (priority > 100)) { KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp)); exit(1); } int scheduler = SuProcess::SchedNormal; if (args->isSet("r")) scheduler = SuProcess::SchedRealtime; if ((priority > 50) || (scheduler != SuProcess::SchedNormal)) { change_uid = true; auth_user = "root"; } // Get command if (args->isSet("c")) { command = args->getOption("c"); for (int i=0; i<args->count(); i++) { command += " "; command += args->arg(i); } } else { if( args->count() == 0 ) { KCmdLineArgs::usage(i18n("No command specified!")); exit(1); } command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i); }}// CJM - Test lines remove when working// kdWarning(1206) << args->count();// kdWarning(1206) << command; // Don't change uid if we're don't need to. if (!change_uid) return system(command); // Check for daemon and start if necessary bool just_started = false; bool have_daemon = true; KDEsuClient client; if (!client.isServerSGID()) { kdWarning(1206) << "Daemon not safe (not sgid), not using it.\n"; have_daemon = false; } else if (client.ping() == -1) { if (client.startServer() == -1) { kdWarning(1206) << "Could not start daemon, reduced functionality.\n"; have_daemon = false; } just_started = true; } // Try to exec the command with kdesud. bool keep = !args->isSet("n") && have_daemon; bool terminal = args->isSet("t"); if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user) != -1) return 0; } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); // Start the dialog KDEsuDialog *dlg = new KDEsuDialog(user, auth_user, keep && !terminal); dlg->addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg->addLine(i18n("Priority:"), prio); } int ret = dlg->exec(); if (ret == KDEsuDialog::Rejected) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg; // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (k && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
QString errorDescriptionText() const { return m_errorDescriptionText; };
virtual QString errorDescriptionText() const { return m_errorDescriptionText; };
QString errorDescriptionText() const { return m_errorDescriptionText; };
QString signalText() const { return m_signalText; };
virtual QString signalText() const { return m_signalText; };
QString signalText() const { return m_signalText; };
bool startedByKdeinit() const { return m_startedByKdeinit; };
virtual bool startedByKdeinit() const { return m_startedByKdeinit; };
bool startedByKdeinit() const { return m_startedByKdeinit; };
curr_scope_node.nodeName() );
(const char*)curr_scope_node.nodeName().utf8() );
_getProperties( QDomDocument const & doc, QMap< QString, PropertyKey > & project_properties ){ QDomNodeList properties = doc.elementsByTagName("properties"); if ( properties.count() > 1 ) { qDebug( "there appears to be more than one ``properties'' XML tag ... bailing" ); return; } else if ( properties.count() < 1 ) // no properties found, so we're done { return; } size_t i = 0; QDomNodeList scopes = properties.item(0).childNodes(); // item(0) because there should only be ONE // "properties" node if ( scopes.count() < 1 ) { qDebug( "empty ``properties'' XML tag ... bailing" ); return; } while ( i < scopes.count() ) { QDomNode curr_scope_node = scopes.item( i ); qDebug( "found %d property node(s) for scope %s", curr_scope_node.childNodes().count(), curr_scope_node.nodeName() ); // DEPRECATED _getScopeProperties( curr_scope_node, project_properties ); if ( ! project_properties[curr_scope_node.nodeName()].readXML( curr_scope_node ) ) { qDebug ("%s:%d unable to read XML for property %s", __FILE__, __LINE__, curr_scope_node.nodeName() ); } ++i; }} // _getProperties
__FILE__, __LINE__, curr_scope_node.nodeName() );
__FILE__, __LINE__, (const char*)curr_scope_node.nodeName().utf8() );
_getProperties( QDomDocument const & doc, QMap< QString, PropertyKey > & project_properties ){ QDomNodeList properties = doc.elementsByTagName("properties"); if ( properties.count() > 1 ) { qDebug( "there appears to be more than one ``properties'' XML tag ... bailing" ); return; } else if ( properties.count() < 1 ) // no properties found, so we're done { return; } size_t i = 0; QDomNodeList scopes = properties.item(0).childNodes(); // item(0) because there should only be ONE // "properties" node if ( scopes.count() < 1 ) { qDebug( "empty ``properties'' XML tag ... bailing" ); return; } while ( i < scopes.count() ) { QDomNode curr_scope_node = scopes.item( i ); qDebug( "found %d property node(s) for scope %s", curr_scope_node.childNodes().count(), curr_scope_node.nodeName() ); // DEPRECATED _getScopeProperties( curr_scope_node, project_properties ); if ( ! project_properties[curr_scope_node.nodeName()].readXML( curr_scope_node ) ) { qDebug ("%s:%d unable to read XML for property %s", __FILE__, __LINE__, curr_scope_node.nodeName() ); } ++i; }} // _getProperties
assert(nl.count() != 0);
if ( 0 == nl.count() ) { return false; }
_getMapLayers( QDomDocument const & doc ){ // Layer order is implicit in the order they are stored in the project file QDomNodeList nl = doc.elementsByTagName("maplayer"); // XXX what is this used for? QString layerCount( QString::number(nl.count()) ); QString wk; // process the map layer nodes assert(nl.count() != 0); for (size_t i = 0; i < nl.count(); i++) { QDomNode node = nl.item(i); QDomElement element = node.toElement(); QString type = element.attribute("type"); QgsMapLayer * mapLayer;#ifdef QGISDEBUG std::cerr << "type is " << type << std::endl; #endif if (type == "vector") { mapLayer = new QgsVectorLayer; } else if (type == "raster") { mapLayer = new QgsRasterLayer; } Q_CHECK_PTR( mapLayer ); if ( ! mapLayer ) {#ifdef QGISDEBUG std::cerr << __FILE__ << " : " << __LINE__ << " unable to create layer\n";#endif return false; } // have the layer restore state that is stored in DOM node mapLayer->readXML( node ); mapLayer = QgsMapLayerRegistry::instance()->addMapLayer( mapLayer ); // XXX kludge for ensuring that overview canvas updates happen correctly; // XXX eventually this should be replaced by mechanism whereby overview // XXX canvas implicitly knows about all new layers// if ( mapLayer ) // if successfully added to registry// {// // find canonical Qgis application object// QgisApp * qgisApp = _findQgisApp();// // make connection// if ( qgisApp )// { // QObject::connect(mapLayer, // SIGNAL(showInOverview(QString,bool)), // qgisApp, // SLOT(setLayerOverviewStatus(QString,bool)));// }// } } return true;} // _getMapLayers
cerr << "fakesyn starting" << endl;
off_t a = 2 << 30; cerr << "fakesyn starting: " << a << " " << a * 60ULL << endl;
int main(int argc, char **argv) { cerr << "fakesyn starting" << endl; vector<char*> args; argv_to_vec(argc, argv, args); parse_config_options(args); int start = 0; parse_syn_options(args); vector<char*> nargs; int mkfs = 0; for (unsigned i=0; i<args.size(); i++) { if (strcmp(args[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; } else if (strcmp(args[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; } else { // unknown arg, pass it on. cerr << " stray arg " << args[i] << endl; nargs.push_back(args[i]); } } assert(nargs.empty()); MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); char hostname[100]; gethostname(hostname,100); //int pid = getpid(); // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { //cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); start++; } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { //cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); start++; } // create client Client *client[NUMCLIENT]; SyntheticClient *syn[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { //cerr << "client" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; client[i] = new Client(new FakeMessenger(MSG_ADDR_CLIENT(i))); start++; } // start message loop fakemessenger_startthread(); // init for (int i=0; i<NUMMDS; i++) { mds[i]->init(); } for (int i=0; i<NUMOSD; i++) { osd[i]->init(); } // create client for (int i=0; i<NUMCLIENT; i++) { client[i]->init(); // use my argc, argv (make sure you pass a mount point!) //cout << "mounting" << endl; client[i]->mount(mkfs); //cout << "starting synthetic client " << endl; syn[i] = new SyntheticClient(client[i]); syn[i]->start_thread(); } for (int i=0; i<NUMCLIENT; i++) { cout << "waiting for synthetic client " << i << " to finish" << endl; syn[i]->join_thread(); delete syn[i]; client[i]->unmount(); //cout << "unmounted" << endl; client[i]->shutdown(); } // wait for it to finish fakemessenger_wait(); // 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; cout << "fakesyn done" << endl; return 0;}
if (arg4) setRectFields(env, arg4, lparg4); if (arg5) setRectFields(env, arg5, lparg5);
JNIEXPORT void JNICALL OS_NATIVE(CopyDeepMask) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jobject arg4, jobject arg5, jshort arg6, jint arg7){ Rect _arg3, *lparg3=NULL; Rect _arg4, *lparg4=NULL; Rect _arg5, *lparg5=NULL; NATIVE_ENTER(env, that, "CopyDeepMask\n") if (arg3) lparg3 = getRectFields(env, arg3, &_arg3); if (arg4) lparg4 = getRectFields(env, arg4, &_arg4); if (arg5) lparg5 = getRectFields(env, arg5, &_arg5); CopyDeepMask((const BitMap *)arg0, (const BitMap *)arg1, (const BitMap *)arg2, (const Rect *)lparg3, (const Rect *)lparg4, (const Rect *)lparg5, (short)arg6, (RgnHandle)arg7); if (arg3) setRectFields(env, arg3, lparg3); if (arg4) setRectFields(env, arg4, lparg4); if (arg5) setRectFields(env, arg5, lparg5); NATIVE_EXIT(env, that, "CopyDeepMask\n")}
if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0);
JNIEXPORT jint JNICALL OS_NATIVE(GetMenuFont) (JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jshortArray arg2){ jshort *lparg1=NULL; jshort *lparg2=NULL; jint rc; NATIVE_ENTER(env, that, "GetMenuFont\n") if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL); rc = (jint)GetMenuFont((MenuRef)arg0, (SInt16 *)lparg1, (UInt16 *)lparg2); if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0); if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0); NATIVE_EXIT(env, that, "GetMenuFont\n") return rc;}
if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
JNIEXPORT jint JNICALL OS_NATIVE(NewControl) (JNIEnv *env, jclass that, jint arg0, jobject arg1, jbyteArray arg2, jboolean arg3, jshort arg4, jshort arg5, jshort arg6, jshort arg7, jint arg8){ Rect _arg1, *lparg1=NULL; jbyte *lparg2=NULL; jint rc; NATIVE_ENTER(env, that, "NewControl\n") if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL); rc = (jint)NewControl((WindowRef)arg0, (const Rect *)lparg1, (ConstStr255Param)lparg2, (Boolean)arg3, (SInt16)arg4, (SInt16)arg5, (SInt16)arg6, (SInt16)arg7, (SInt32)arg8); if (arg1) setRectFields(env, arg1, lparg1); if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); NATIVE_EXIT(env, that, "NewControl\n") return rc;}
if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
JNIEXPORT jint JNICALL OS_NATIVE(TXNSetTXNObjectControls) (JNIEnv *env, jclass that, jint arg0, jboolean arg1, jint arg2, jintArray arg3, jintArray arg4){ jint *lparg3=NULL; jint *lparg4=NULL; jint rc; NATIVE_ENTER(env, that, "TXNSetTXNObjectControls\n") if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); rc = (jint)TXNSetTXNObjectControls((TXNObject)arg0, (Boolean)arg1, (ItemCount)arg2, (const TXNControlTag *)lparg3, (const TXNControlData *)lparg4); if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); NATIVE_EXIT(env, that, "TXNSetTXNObjectControls\n") return rc;}
QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) {
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-2002, 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" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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(); 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); } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(KCGlobal::baseGroup(), 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; } } dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8);
cout << i18n("The following modules are available:").local8Bit() << endl;
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-2002, 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" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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(); 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); } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(KCGlobal::baseGroup(), 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; } } dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); }
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;
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-2002, 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" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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(); 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); } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(KCGlobal::baseGroup(), 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; } } dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
QByteArray vl; vl.fill(' ', 80); QString verylong = vl;
for (module=modules.first(); module != 0; module=modules.next()) {
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-2002, 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" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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(); 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); } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(KCGlobal::baseGroup(), 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; } } dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(),
QString entry("%1 - %2");
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-2002, 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" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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(); 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); } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(KCGlobal::baseGroup(), 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; } } dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
(*descriptions.at(i)).local8Bit().data());
entry = entry.arg(stripPath(module->fileName()).leftJustify(maxLen, ' ')); entry = entry.arg(!module->comment().isEmpty() ? module->comment() : i18n("No description available")); cout << entry.local8Bit() << endl;
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-2002, 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" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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(); 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); } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(KCGlobal::baseGroup(), 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; } } dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
KCModule *create_filetypes(QWidget *parent, const char *)
KDE_EXPORT KCModule *create_filetypes(QWidget *parent, const char *)
KCModule *create_filetypes(QWidget *parent, const char *) { return new FileTypesView(parent, "filetypes"); }
QString url="devices:/"+(*it);
QString url="devices:/"+KURL::encode_string_no_slash(*it);
void DevicesProtocol::listRoot(){ KIO::UDSEntry entry; uint count; QStringList list=deviceList(); count=0; for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { if ((*it)=="!!!ERROR!!!") { error(KIO::ERR_SLAVE_DEFINED,i18n("The KDE mountwatcher is not running. Please activate it in Control Center->KDE Components->Service Manager, if you want to use the devices:/ protocol")); return; }// FIXME: look for the real ending ++it; QString url="devices:/"+(*it); //++it; QString name=*it; ++it; ++it; ++it; QString type=*it; ++it; ++it; createFileEntry(entry,name,url,type); listEntry(entry,false); count++; } totalSize(count); listEntry(entry, true); // Jobs entry // finish finished();}
kdDebug()<<"kdemain for devices"<<endl; KInstance instance( "kio_devices" );
kdDebug()<<"kdemain for settings kioslave"<<endl; KInstance instance( "kio_settings" );
int kdemain( int, char **argv ) { kdDebug()<<"kdemain for devices"<<endl; KInstance instance( "kio_devices" ); SettingsProtocol slave(argv[1], argv[2], argv[3]); slave.dispatchLoop(); return 0; }
addAtom(entry, KIO::UDS_CREATION_TIME,0);
addAtom(entry, KIO::UDS_CREATION_TIME,1);
static void createFileEntry(KIO::UDSEntry& entry, const QString& name, const QString& url, const QString& mime){ entry.clear(); addAtom(entry, KIO::UDS_NAME, 0, name); addAtom(entry, KIO::UDS_FILE_TYPE, S_IFDIR);//REG); addAtom(entry, KIO::UDS_URL, 0, url); addAtom(entry, KIO::UDS_ACCESS, 0500); addAtom(entry, KIO::UDS_MIME_TYPE, 0, mime); addAtom(entry, KIO::UDS_SIZE, 0); addAtom(entry, KIO::UDS_GUESSED_MIME_TYPE, 0, "inode/directory"); addAtom(entry, KIO::UDS_CREATION_TIME,0); addAtom(entry, KIO::UDS_MODIFICATION_TIME,time(0));}