char *copy_str(const char *ostr) { auto char *cstr = NULL; if(!ostr) vexit("!ostr", EX_SOFTWARE); cstr = malloc(1 + strlen(ostr)); strcpy(cstr, ostr); return cstr; }
int main(int argc,char**argv){ int sock,port,len; struct hostent *he; char str[4096],buf[4096],*sln,*op,c; struct sockaddr_in ta; if(argc<3){ printf("napstir by S\n"); printf("usage: %s host file [port] [username]\n",argv[0]); printf("example: %s metallica.com ",argv[0]); printf("\"\\etc\\passwd\" 6699\n"); printf("default port is 6699\n"); printf("default username is Lamer (usually not required)\n"); exit(EXIT_SUCCESS); } if(!(he=gethostbyname(argv[1])))vexit("gethostbyname"); ta.sin_family=AF_INET; ta.sin_addr=*((struct in_addr*)he->h_addr); if(argv[3]){ port=strtol(argv[3],(char**)0,10); if(errno==ERANGE)vexit("strtol"); } else port=6699; ta.sin_port=htons(port); memset(&ta.sin_zero,0,sizeof(ta.sin_zero)); if((sock=socket(AF_INET,SOCK_STREAM,0))<0)vexit("socket"); if(connect(sock,(struct sockaddr*)&ta,sizeof(struct sockaddr))<0) vexit("connect"); /* I wonder what this byte is for. */ recv(sock,&buf,1,0); /* 9 is the code for T1 bitrate -- Most clients ignore the username * field. */ sprintf(str,"%s \"%s\" 9",(argc>=4)?argv[4]:"Lamer",argv[2]); send(sock,"GET",3,0); send(sock,(char*)str,strlen(str),0); /* * SERVICE DENIAL CODE * * Uncomment this line if you'd like to crash knapster. :-) * send(sock,"0",1); */ if(!(op=sln=(char*)malloc(1024)))vexit("malloc"); do { read(sock,&c,1); sprintf(sln,"%c",c); sln++; } while(isdigit(c)); *sln=0; sln=op; len=strtol(sln,(char**)0,10); if(errno==ERANGE)vexit("strtol"); write(STDOUT_FILENO,&c,1); if((port=read(sock,&buf,len-1))<0)vexit("read"); write(STDOUT_FILENO,buf,port); exit(EXIT_SUCCESS); }
main() { char dev[20]; int i; fprintf(stderr,"Enter device: "); gets(dev); vinit(dev); color(BLACK); clear(); /* * Set up two viewports (They actually overlap) */ viewport(-1.0, 0.3, -1.0, 0.3); ortho(-2.0, 5.0, -2.0, 5.0, -2.0, 5.0); lookat(0.0, 0.0, 0.0, -3.0, 2.0, -4.0, 0.0); /* * Save it */ pushviewport(); pushmatrix(); viewport(-0.3, 1.0, -0.3, 1.0); ortho(-2.0, 5.0, -2.0, 5.0, -2.0, 5.0); lookat(0.0, 0.0, 0.0, 3.0, 2.0, -4.0, 0.0); textsize(0.4, 0.4); /* * patchcurves provides a number of curves in the t and u * directions. patchprecision gives the minimum number of line * segments making up the curves in the t and u directions. The * actual number of linesegments in t or u is equal to the closest * integer multiple of the number of curves, > nsegs, in t or u, * greater than or equal to the number set by patchprecision in u or * t. eg. curves in t will be made up of 21 line segments so that we * can match up the 7 curves in u; curves in u will have 24 as 4 by 5 * gives 20. */ patchcurves(4, 7); patchprecision(20, 20); for (i = 0; i < 4; i++) { axes(); /* * patchbasis sets the basis matrices for the t and u * functions * */ patchbasis(basis[i], basis[i]); /* * Draw with viewport 2 */ move(0.0, 4.0, 0.0); drawstr(labels[i]); /* * now draw the patches according to the geometry matrices in * x1, y1, and z1, x2, y2, z2. */ drawhull(x1, y1, z1); patch(x1, y1, z1); drawhull(x2, y2, z2); patch(x2, y2, z2); getkey(); /* * Now with viewport 1 */ popviewport(); popmatrix(); axes(); move(0.0, 4.0, 0.0); drawstr(labels[i]); /* * now draw the patches according to the geometry matrices in * x1, y1, and z1, x2, y2, z2. */ drawhull(x1, y1, z1); patch(x1, y1, z1); drawhull(x2, y2, z2); patch(x2, y2, z2); getkey(); /* * Save viewport 1 again and reset to viewport 2 */ pushviewport(); pushmatrix(); viewport(-0.3, 1.0, -0.3, 1.0); ortho(-1.5, 5.0, -1.5, 5.0, -1.5, 5.0); lookat(0.0, 0.0, 0.0, 3.0, 2.0, -4.0, 0.0); color(BLACK); clear(); } vexit(); }
int main(int argc, char *argv[]) { FILE *fsi = NULL; FILE *fsx = NULL; char *domain; char *domain_dir = NULL; static struct stat statbuf; domain_entry *entry; memset(TmpBuf,0,sizeof(TmpBuf)); memset(MsgBuf,0,sizeof(MsgBuf)); Verbose = 0; DoNothing = 0; if ( argc == 1 ) { usage(); vexit(-1); } if( vauth_open( 1 )) { vexiterror( stderr, "Initial open." ); } get_options(argc,argv); getcwd(CurDir,sizeof(CurDir)); if ( EmailFileFlag == 1 ) { if ( (fsi = fopen(EmailFile, "r")) == NULL ) { fprintf(stderr, "Could not open file %s\n", EmailFile); vexit(-1); } else { /* make sure the file size is not 0 */ stat(EmailFile, &statbuf); if(statbuf.st_size == 0) { fprintf(stderr, "Error: %s is empty\n", EmailFile); vexit(-1); } /* check for existing date header */ while (fgets (TmpBuf, sizeof(TmpBuf), fsi) != NULL) { /* check for end of headers (blank line) */ if (*TmpBuf == '\n') break; if (strncasecmp ("Date: ", TmpBuf, 6) == 0) { InsertDate = 0; break; } } rewind(fsi); } } else if (! DoNothing) { /* require -f [email_file] */ fprintf(stderr, "Error: email_file not specified\n"); usage(); vexit(-1); } if ( ExcludeFileFlag == 1 ) { if ( (fsx = fopen(ExcludeFile, "r")) == NULL ) { fprintf(stderr, "Could not open file %s\n", ExcludeFile); vexit(-1); } } if (( EmailFile[0] != 0 || DoNothing == 1) && Domain[0] != 0 ) { /* Process list of domains */ domain = strtok(Domain, " "); while (domain != NULL ) { if((vget_assign(domain, domain_dir, sizeof(domain_dir), NULL, NULL)) != NULL) { process_domain(domain, fsi, fsx ); } else { fprintf(stderr, "Error: domain %s does not exist\n", domain); } domain = strtok(NULL, " "); } vexit(0); } else if ( (EmailFile[0] != 0 || DoNothing == 1) && Domain[0] == 0 ) { entry = get_domain_entries( "" ); if (entry==NULL) { if( verrori ) { printf("Can't get domain entries - %s\n", verror( verrori )); vexit(-1); } else { printf("What now - %s\n", verror( verrori )); vexit(0); } } while( entry ) { if (strcmp (entry->domain, entry->realdomain) != 0) { if (Verbose) { fprintf (stderr, "skipping %s (alias of %s)\n", entry->domain, entry->realdomain); } } else { chdir(entry->path); process_domain(entry->realdomain, fsi, fsx ); } entry = get_domain_entries(NULL); } } return(vexit(0)); }
main() { char device[10], *p; float x, y, tdir = TRANS; int but, nplanes; int i, n; char buf[10][128]; fprintf(stderr,"Enter output device: "); gets(device); prefposition(50, 50); vinit(device); window(-800.0, 800.0, -800.0, 800.0, -800.0, 800.0); lookat(0.0, 0.0, 1500.0, 0.0, 0.0, 0.0, 0.0); makeobj(1); makepoly(); rect(-CUBE_SIZE, -CUBE_SIZE, CUBE_SIZE, CUBE_SIZE); closepoly(); closeobj(); if ((nplanes = getdepth()) == 1) makecubes(0); makecubes(1); backface(1); if (backbuffer() < 0) { vexit(); fprintf(stderr, "lcube: device doesn't support double buffering.\n"); exit(0); } while((but = slocator(&x, &y)) != 44) { pushmatrix(); rotate(100.0 * x, 'y'); rotate(100.0 * y, 'x'); color(BLACK); clear(); callobj(3); if (nplanes == 1) callobj(2); popmatrix(); swapbuffers(); switch (but = checkkey()) { case 'x': translate(tdir, 0.0, 0.0); break; case 'y': translate(0.0, tdir, 0.0); break; case 'z': translate(0.0, 0.0, tdir); break; case '-': tdir = -tdir; break; case '+': tdir = TRANS; break; case 27: /* ESC */ case 'q': vexit(); exit(0); default: ; } } vexit(); }
int main() { #ifndef USE_SQL FILE *fs_smtp_cur; FILE *fs_smtp_tmp; char *tmpstr; time_t file_time; #endif /* ndef USE_SQL */ time_t mytime; time_t clear_minutes; if( vauth_open( 0 )) { vexiterror( stderr, "Initial open." ); } clear_minutes = RELAY_CLEAR_MINUTES * 60; mytime = time(NULL); #ifdef USE_SQL /* scan the relays table in mysql, and purge out any * entries that are older than our specified timestamp */ vclear_open_smtp(clear_minutes, mytime); #else /* OPEN_SMTP_CUR_FILE is typically ~vpopmail/etc/open-smtp */ fs_smtp_cur = fopen(OPEN_SMTP_CUR_FILE, "r+"); if ( fs_smtp_cur != NULL ) { /* OPEN_SMTP_TMP_FILE is typically ~vpopmail/etc/open-smtp.tmp */ /* create this file */ fs_smtp_tmp = fopen(OPEN_SMTP_TMP_FILE, "w+"); if ( fs_smtp_tmp == NULL ) { printf ("Error, could not create open-smtp.tmp\n"); vexit(-1); } /* read in the contents of the open-smtp file */ while ( fgets(TmpBuf1, MAX_BUFF, fs_smtp_cur ) != NULL ) { /* format is x.x.x.x:ALLOW,RELAYCLIENT="",RBLSMTPD=""<TAB>timestamp */ snprintf(TmpBuf2, sizeof(TmpBuf2), "%s", TmpBuf1); tmpstr = strtok( TmpBuf2, "\t"); tmpstr = strtok( NULL, "\t"); /* extract the timestamp for this line */ if ( tmpstr != NULL ) { /* compare the timestamp to see if it is not too old */ file_time = atoi(tmpstr); if ( file_time + clear_minutes > mytime) { /* if not too old, copy line out to .tmp file */ fputs(TmpBuf1, fs_smtp_tmp); } } } fclose(fs_smtp_cur); fclose(fs_smtp_tmp); /* replace open-relay with open-relay.tmp */ rename(OPEN_SMTP_TMP_FILE, OPEN_SMTP_CUR_FILE); /* set correct permissions on file */ chown(OPEN_SMTP_CUR_FILE,VPOPMAILUID,VPOPMAILGID); } #endif /* Now, regardless of backend, build a new tcp.smtp.cdb file * * For mysql this involves combining the tcp.smtp file with * the contents of the relay table. * For cdb this involves combining the tcp.smtp file with * the contents of the open-relay file. * The resultant file will then be compiled by the tcprules tool * to make a new tcp.smtp.cdb file for tcpserver to use */ update_rules(); return(vexit(0)); }
int main() { printf("vpopmail not configure with --enable-roaming-users\n"); return(vexit(0)); }
void AFNI_start_fetching_url( char *urlstring ) { pid_t child_pid ; #ifdef CYGWIN /* 18 Dec 2002 */ FAIL_MESSAGE("not possible under Cygwin") ; return ; #else /*-- decide if we are to do anything --*/ if( ! AFNI_yesenv("AFNI_VERSION_CHECK") ){ /* never check */ FAIL_MESSAGE("AFNI_VERSION_CHECK forbids") ; return ; } #undef VDELAY #define VDELAY 1234567 /* about 2 weeks */ /* check if we did this in the last VDELAY seconds */ /* also, update global motd_old */ if( vc_check_too_soon() ) { disabled = 1 ; return ; } /*-- OK, start the child process --*/ child_pid = fork() ; if( child_pid == (pid_t)(-1) ){ /* bad */ FAIL_MESSAGE("can't fork") ; return ; } /*---------------------------------------------------------*/ if( child_pid > 0 ){ /* I'm the parent */ /*-- save PID of child for later use --*/ vc_child_pid = child_pid ; /*-- open an IOCHAN to talk to child --*/ vc_ioc = iochan_init( STR_CHILD , "accept" ) ; if( vc_ioc == NULL ){ kill(child_pid,SIGTERM) ; /* cf. Abraham and Isaac */ vc_child_pid = (pid_t)(-1) ; FAIL_MESSAGE("can't open connection to child") ; } else { atexit( vc_exit ) ; /* 12 Dec 2002 */ } return ; /*---------------------------------------------------------*/ } else { /* I'm the child */ /* (never returns) */ int nbuf=0 , jj ; char *vbuf=NULL ; IOCHAN *ioc ; struct utsname ubuf ; char ua[512] ; iochan_enable_perror(0) ; /* don't print TCP/IP error messages */ signal( SIGTERM , vexit ) ; /* if parent kills us, call vexit() */ /*-- get information from the AFNI server --*/ #define USE_HTTP_10 #ifdef USE_HTTP_10 # undef PCLAB # ifdef SHOWOFF # undef SHSH # undef SHSHSH # define SHSH(x) #x # define SHSHSH(x) SHSH(x) # define PCLAB SHSHSH(SHOWOFF) # else # define PCLAB "Unknown" # endif #endif /** 25 Mar 2005: send more info in the request header **/ #ifdef USE_HTTP_10 ubuf.nodename[0] = ubuf.sysname[0] = ubuf.machine[0] = '\0' ; jj = uname( &ubuf ) ; if( jj >= 0 && ubuf.nodename[0] != '\0' ) sprintf( ua , "afni (avers='%s'; prec='%s' node='%s'; sys='%s'; mach='%s')" , AVERZHN, PCLAB, ubuf.nodename, ubuf.sysname, ubuf.machine ) ; else sprintf( ua , "afni (avers='%s'; prec='%s')" , AVERZHN , PCLAB ) ; set_HTTP_10( 1 ) ; set_HTTP_user_agent( ua ) ; #else set_HTTP_10( 0 ) ; #endif /* send the request */ THD_death_setup( 34567 ) ; /* die if 34.567 seconds passes away */ nbuf = read_URL( urlstring , &vbuf ) ; /* may take a while */ set_HTTP_10( 0 ) ; /*-- if this failed, quit --*/ if( nbuf <= 0 || vbuf == NULL || vbuf[0] == '\0' ) { /* block recheck until a new DELAY has passed 22 Mar 2016 [rickr] */ /* - also so server is not flooded when there are issues */ AFNI_update_vctime(NULL, NULL); vexit(1); } /*-- talk to parent process thru IOCHAN --*/ ioc = iochan_init( STR_CHILD , "create" ) ; if( ioc == NULL ) vexit(2); /*-- wait until ioc is ready for writing --*/ jj = iochan_writecheck(ioc,-1) ; if( jj < 0 ) vexit(3); /*-- send the info in vbuf --*/ iochan_sendall( ioc , vbuf , nbuf ) ; while( ! iochan_clearcheck(ioc,10) ) /* loop until cleared */ AFNI_sleep(10) ; /* by parent process */ AFNI_sleep(10); /* a little extra napping, then death */ _exit(0); } #endif /* not CYGWIN */ }
int main(int argc, char *argv[]) { int fd; int ret = 0; parse_opts(argc, argv); if (speed > 2000000 || speed < 10000) { if ( verbose ) { vexit("Invalid speed, speed must be between 10000 and 2000000"); } else { vexit("E"); } } if ( input > 7 || input < 0 ) { if ( verbose ) { vexit("Invalid input, input must be between 0 and 7"); } else { vexit("E"); } } fd = open(device, O_RDWR); if (fd < 0) { if ( verbose ) { printf("%s\n", device); pabort("can't open device"); } else { vexit("E"); } } /* * spi mode */ ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); if (ret == -1 ) { close(fd); if ( verbose ) { pabort("can't set spi mode"); } else { vexit("E"); } } ret = ioctl(fd, SPI_IOC_RD_MODE, &mode); if (ret == -1) { close(fd); if ( verbose ) { pabort("can't get spi mode"); } else { vexit("E"); } } /* * bits per word */ ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); if (ret == -1) { close(fd); if ( verbose ) { pabort("can't set bits per word"); } else { vexit("E"); } } ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits); if (ret == -1) { close(fd); if ( verbose ) { pabort("can't get bits per word"); } else { vexit("E"); } } /* * max speed hz */ ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); if (ret == -1) { close(fd); if ( verbose ) { pabort("can't set max speed hz"); } else { vexit("E"); } } ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed); if (ret == -1) { close(fd); if ( verbose ) { pabort("can't get max speed hz"); } else { vexit("E"); } } if ( verbose ) { printf("device: %s\n", device); printf("spi mode: %d\n", mode); printf("bits per word: %d\n", bits); printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000); printf("input port %d\n", input); } if ( verbose ) { if ( chip ) { printf("chip MAX1204\n"); } else { printf("chip MAX1202 or MAX1203\n"); } } uint8_t transmitbyte = 0b10000000; transmitbyte |= inputtable[input]; if ( unipolar ) { transmitbyte |= unipolar; if ( verbose ) { printf("unipolar mode\n"); } } else { if ( verbose ) { printf("bipolar mode\n"); } } if ( single ) { if (verbose ) { printf("single ended mode\n"); } transmitbyte |= single; } else { if ( verbose ) { printf("diferential mode"); } } transmitbyte |= clock; if ( verbose ) { if ( clock == 3 ) { printf("external clock mode\n"); } else { printf("internal clock mode\n"); } } if ( verbose ) { printf("transmit byte %d\n", transmitbyte); } uint8_t tx[] = { transmitbyte, 0, 0 }; // printf("Array tx dimension: %d\n", ARRAY_SIZE(tx)); uint8_t rx[ARRAY_SIZE(tx)] = {0,}; struct spi_ioc_transfer tr = { .tx_buf = (unsigned long)tx, .rx_buf = (unsigned long)rx, .len = ARRAY_SIZE(tx), .delay_usecs = delay, .speed_hz = speed, .bits_per_word = bits, .cs_change = deselect, }; ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); if (ret < 1) { close(fd); if ( verbose ) { pabort("can't send spi message"); } else { vexit("E"); } } close(fd); unsigned int first_byte = rx[ARRAY_SIZE(rx) - 3]; unsigned int second_byte = rx[ARRAY_SIZE(rx) - 2]; unsigned int third_byte = rx[ARRAY_SIZE(rx) - 1]; if ( verbose ) { printf("First byte: %d\n", first_byte); printf("Second byte %d\n", second_byte); printf("Third byte %d\n", third_byte); } if ( first_byte && !chip ) { close(fd); if ( verbose ) { perror("Protocol error: the first byte is not 0!"); } else { vexit("E"); } } if ( second_byte > 127 ) { close(fd); if ( verbose ) { perror("Protocol error: the first bit of the second byte must be 0!"); } else { vexit("E"); } } unsigned int padding; padding = 7; if ( ( third_byte & padding ) != 0 ) { close(fd); if ( verbose ) { perror("Protocol error: the last three bit of the third byte must be 0"); } else { vexit("E"); } } signed long lettura; if ( chip ) { lettura = third_byte >> 5; lettura |= second_byte << 3; bipolarconvert = 511; lsb = MAX124_lsb; } else { lettura = third_byte >> 3; lettura |= second_byte << 5; } if ( !unipolar ) { if ( verbose ) { printf("unipolar algorithm\n"); } if ( lettura > bipolarconvert ) { lettura &= bipolarconvert; lettura -= bipolarconvert; lettura -= 1; if ( verbose ) { printf("Negative vaule"); } } } float volt = lettura * lsb; if ( fullscale ) { volt = volt * fullscale / 4.096; if ( verbose ) { printf("Fullscale is %f\n", fullscale); } } if ( raw ) { if ( verbose ) { printf("Raw read: "); } printf("%d", lettura); } else { if ( verbose ) { printf("Analog read: "); } printf("%f", volt); } if ( newline || verbose ) { printf("\n"); } }
int main(int argc, char *argv[]) { int i; char OptionString[MAX_BUFF]; if( vauth_open( 1 )) { vexiterror( stderr, "Initial open." ); } get_options(argc,argv); if (EditDefaultLimits || vget_assign(Domain, NULL, 0, NULL, NULL ) != NULL) { if (EditDefaultLimits) { if (vlimits_read_limits_file(VLIMITS_DEFAULT_FILE, &limits) != 0) { printf ("Failed to read the vlimits.default file.\n"); vexit(-1); } if (DeleteLimits) { printf ("Default limits must not be deleted. If you really want to do this,\n"); printf ("remove the vlimits.default file.\n"); printf ("But be warned: this might stop vpopmail from working!!\n"); vexit(-1); } } else { if (vget_limits(Domain,&limits) != 0) { printf ("Failed to vget_limits\n"); vexit(-1); } if (DeleteLimits) { if (vdel_limits(Domain)==0) { printf ("Limits deleted\n"); vexit(0); } else { printf ("Failed to delete limits\n"); vexit(-1); } } } if (ShowLimits) { memset (OptionString, 0, sizeof(OptionString)); if (EditDefaultLimits) printf("Default limits: %s\n", VLIMITS_DEFAULT_FILE); else printf("Domain: %s\n", Domain); printf("--\n"); printf("Max Pop Accounts: %d\n", limits.maxpopaccounts); printf("Max Aliases: %d\n", limits.maxaliases); printf("Max Forwards: %d\n", limits.maxforwards); printf("Max Autoresponders: %d\n", limits.maxautoresponders); printf("Max Mailinglists: %d\n", limits.maxmailinglists); printf("GID Flags:\n"); if (limits.disable_imap != 0) { printf(" NO_IMAP\n"); strncat(OptionString, "i", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_smtp != 0) { printf(" NO_SMTP\n"); strncat(OptionString, "s", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_pop != 0) { printf(" NO_POP\n"); strncat(OptionString, "p", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_webmail != 0) { printf(" NO_WEBMAIL\n"); strncat(OptionString, "w", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_passwordchanging != 0) { printf(" NO_PASSWD_CHNG\n"); strncat(OptionString, "d", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_relay != 0) { printf(" NO_RELAY\n"); strncat(OptionString, "r", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_dialup != 0) { printf(" NO_DIALUP\n"); strncat(OptionString, "u", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_spamassassin != 0) { printf(" NO_SPAMASSASSIN\n"); strncat(OptionString, "c", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.delete_spam != 0) { printf(" DEL_SPAM\n"); strncat(OptionString, "x", sizeof(OptionString)-strlen(OptionString)-1); } if (limits.disable_maildrop != 0) { printf(" NO_MAILDROP\n"); strncat(OptionString, "m", sizeof(OptionString)-strlen(OptionString)-1); } printf("Flags (for commandline): %s\n", OptionString); printf("Flags for non postmaster accounts:"); printf("\n pop account: "); printf ((limits.perm_account & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_account & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_account & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n alias: "); printf ((limits.perm_alias & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_alias & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_alias & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n forward: "); printf ((limits.perm_forward & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_forward & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_forward & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n autoresponder: "); printf ((limits.perm_autoresponder & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_autoresponder & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_autoresponder & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n mailinglist: "); printf ((limits.perm_maillist & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_maillist & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_maillist & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n mailinglist users: "); printf ((limits.perm_maillist_users & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_maillist_users & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_maillist_users & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n mailinglist moderators: "); printf ((limits.perm_maillist_moderators & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_maillist_moderators & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_maillist_moderators & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n quota: "); printf ((limits.perm_quota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_quota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_quota & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n default quota: "); printf ((limits.perm_defaultquota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE " :"ALLOW_CREATE ") ); printf ((limits.perm_defaultquota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY " :"ALLOW_MODIFY ") ); printf ((limits.perm_defaultquota & VLIMIT_DISABLE_DELETE ? "DENY_DELETE " :"ALLOW_DELETE ") ); printf("\n"); printf("Domain Quota: %d MB\n", limits.diskquota); printf("Default User Quota: %d bytes\n", limits.defaultquota); printf("Max Domain Messages: %d\n", limits.maxmsgcount); printf("Default Max Messages per User: %d\n", limits.defaultmaxmsgcount); return(vexit(0)); } if (MaxPopAccounts[0] != 0) { limits.maxpopaccounts = atoi(MaxPopAccounts); } if (MaxAliases[0] != 0) { limits.maxaliases = atoi(MaxAliases); } if (MaxForwards[0] != 0) { limits.maxforwards = atoi(MaxForwards); } if (MaxAutoresponders[0] != 0) { limits.maxautoresponders = atoi(MaxAutoresponders); } if (MaxMailinglists[0] != 0) { limits.maxmailinglists = atoi(MaxMailinglists); } /* quota & message count limits */ if (DomainQuota[0] != 0) { limits.diskquota = atoi(DomainQuota); } if (DomainMaxMsgCount[0] != 0) { limits.maxmsgcount = atoi(DomainMaxMsgCount); } if (DefaultUserQuota[0] != 0) { limits.defaultquota = atoi(format_maildirquota(DefaultUserQuota)); } if (DefaultUserMaxMsgCount[0] != 0) { limits.defaultmaxmsgcount = atoi(DefaultUserMaxMsgCount); } if (GidFlag == 1) { GidFlag = 0; limits.disable_dialup = 0; limits.disable_passwordchanging = 0; limits.disable_pop = 0; limits.disable_smtp = 0; limits.disable_webmail = 0; limits.disable_imap = 0; limits.disable_relay = 0; limits.disable_spamassassin = 0; limits.delete_spam = 0; limits.disable_maildrop = 0; for (i=0; i<(int)strlen(GidFlagString); i++) { switch(GidFlagString[i]) { case 'u': limits.disable_dialup = 1; break; case 'd': limits.disable_passwordchanging = 1; break; case 'p': limits.disable_pop = 1; break; case 's': limits.disable_smtp = 1; break; case 'w': limits.disable_webmail = 1; break; case 'i': limits.disable_imap = 1; break; case 'r': limits.disable_relay = 1; break; case 'c': limits.disable_spamassassin = 1; break; case 'x': limits.delete_spam = 1; break; case 'm': limits.disable_maildrop = 1; break; } } } if (PermAccountFlag == 1) { limits.perm_account=0; for (i=0; i<(int)strlen(PermAccountFlagString); i++) { switch(PermAccountFlagString[i]) { case 'a': limits.perm_account|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_account|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_account|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_account|=VLIMIT_DISABLE_DELETE; break; } } } if (PermAliasFlag == 1) { limits.perm_alias=0; for (i=0; i<(int)strlen(PermAliasFlagString); i++) { switch(PermAliasFlagString[i]) { case 'a': limits.perm_alias|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_alias|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_alias|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_alias|=VLIMIT_DISABLE_DELETE; break; } } } if (PermForwardFlag == 1) { limits.perm_forward=0; for (i=0; i<(int)strlen(PermForwardFlagString); i++) { switch(PermForwardFlagString[i]) { case 'a': limits.perm_forward|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_forward|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_forward|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_forward|=VLIMIT_DISABLE_DELETE; break; } } } if (PermAutoresponderFlag == 1) { limits.perm_autoresponder=0; for (i=0; i<(int)strlen(PermAutoresponderFlagString); i++) { switch(PermAutoresponderFlagString[i]) { case 'a': limits.perm_autoresponder|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_autoresponder|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_autoresponder|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_autoresponder|=VLIMIT_DISABLE_DELETE; break; } } } if (PermMaillistFlag == 1) { limits.perm_maillist=0; for (i=0; i<(int)strlen(PermMaillistFlagString); i++) { switch(PermMaillistFlagString[i]) { case 'a': limits.perm_maillist|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_maillist|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_maillist|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_maillist|=VLIMIT_DISABLE_DELETE; break; } } } if (PermMaillistUsersFlag == 1) { limits.perm_maillist_users=0; for (i=0; i<(int)strlen(PermMaillistUsersFlagString); i++) { switch(PermMaillistUsersFlagString[i]) { case 'a': limits.perm_maillist_users|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_maillist_users|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_maillist_users|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_maillist_users|=VLIMIT_DISABLE_DELETE; break; } } } if (PermMaillistModeratorsFlag == 1) { limits.perm_maillist_moderators=0; for (i=0; i<(int)strlen(PermMaillistModeratorsFlagString); i++) { switch(PermMaillistModeratorsFlagString[i]) { case 'a': limits.perm_maillist_moderators|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_maillist_moderators|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_maillist_moderators|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_maillist_moderators|=VLIMIT_DISABLE_DELETE; break; } } } if (PermQuotaFlag == 1) { limits.perm_quota=0; for (i=0; i<(int)strlen(PermQuotaFlagString); i++) { switch(PermQuotaFlagString[i]) { case 'a': limits.perm_quota|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_quota|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_quota|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_quota|=VLIMIT_DISABLE_DELETE; break; } } } if (PermDefaultQuotaFlag == 1) { limits.perm_defaultquota=0; for (i=0; i<(int)strlen(PermDefaultQuotaFlagString); i++) { switch(PermDefaultQuotaFlagString[i]) { case 'a': limits.perm_defaultquota|=VLIMIT_DISABLE_ALL; break; case 'c': limits.perm_defaultquota|=VLIMIT_DISABLE_CREATE; break; case 'm': limits.perm_defaultquota|=VLIMIT_DISABLE_MODIFY; break; case 'd': limits.perm_defaultquota|=VLIMIT_DISABLE_DELETE; break; } } } if (EditDefaultLimits) { if (vlimits_write_limits_file(VLIMITS_DEFAULT_FILE, &limits)) { printf ("Failed to write vlimits.default file"); return (vexit(-1)); } } else { if (vset_limits(Domain,&limits) != 0) { printf ("Failed to vset_limits\n"); return (vexit(-1)); } } } return(vexit(0)); }
void get_options(int argc,char **argv) { int c; int errflag; extern char *optarg; extern int optind; memset(Domain, 0, sizeof(Domain)); memset(DomainQuota, 0, sizeof(DomainQuota)); memset(DefaultUserQuota, 0, sizeof(DefaultUserQuota)); memset(DomainMaxMsgCount, 0, sizeof(DomainMaxMsgCount)); memset(DefaultUserMaxMsgCount, 0, sizeof(DefaultUserMaxMsgCount)); memset(MaxPopAccounts, 0, sizeof(MaxPopAccounts)); memset(MaxAliases, 0, sizeof(MaxAliases)); memset(MaxForwards, 0, sizeof(MaxForwards)); memset(MaxAutoresponders, 0, sizeof(MaxAutoresponders)); memset(MaxMailinglists, 0, sizeof(MaxMailinglists)); memset(GidFlagString, 0, sizeof(GidFlagString)); memset(PermAccountFlagString,0, sizeof(PermAccountFlagString)); memset(PermAliasFlagString,0, sizeof(PermAliasFlagString)); memset(PermForwardFlagString,0, sizeof(PermForwardFlagString)); memset(PermAutoresponderFlagString,0, sizeof(PermAutoresponderFlagString)); memset(PermMaillistFlagString,0, sizeof(PermMaillistFlagString)); memset(PermMaillistUsersFlagString,0, sizeof(PermMaillistUsersFlagString)); memset(PermMaillistModeratorsFlagString,0, sizeof(PermMaillistModeratorsFlagString)); memset(PermQuotaFlagString,0, sizeof(PermQuotaFlagString)); memset(PermDefaultQuotaFlagString,0, sizeof(PermDefaultQuotaFlagString)); QuotaFlag = 0; GidFlag = 0; PermAccountFlag = 0; PermAliasFlag = 0; PermForwardFlag = 0; PermAutoresponderFlag = 0; PermMaillistFlag = 0; PermMaillistUsersFlag = 0; PermMaillistModeratorsFlag = 0; PermQuotaFlag = 0; PermDefaultQuotaFlag = 0; //NoMakeIndex = 0; ShowLimits = 0; DeleteLimits = 0; EditDefaultLimits = 0; errflag = 0; while( (c=getopt(argc,argv,"vSDdQ:q:M:m:P:A:F:R:L:g:p:a:f:r:l:u:o:x:z:h")) != -1 ) { switch(c) { case 'v': printf("version: %s\n", VERSION); break; case 'S': ShowLimits = 1; break; case 'D': DeleteLimits = 1; break; case 'd': EditDefaultLimits = 1; snprintf(Domain, sizeof(Domain), "Default limits: %s", VLIMITS_DEFAULT_FILE); break; case 'Q': snprintf(DomainQuota, sizeof(DomainQuota), "%s", optarg); break; case 'q': snprintf(DefaultUserQuota, sizeof(DefaultUserQuota), "%s", optarg); break; case 'M': snprintf(DomainMaxMsgCount, sizeof(DomainMaxMsgCount), "%s", optarg); break; case 'm': snprintf(DefaultUserMaxMsgCount, sizeof(DefaultUserMaxMsgCount), "%s", optarg); break; case 'P': snprintf(MaxPopAccounts, sizeof(MaxPopAccounts), "%s", optarg); break; case 'A': snprintf(MaxAliases, sizeof(MaxAliases), "%s", optarg); break; case 'F': snprintf(MaxForwards, sizeof(MaxForwards), "%s", optarg); break; case 'R': snprintf(MaxAutoresponders, sizeof(MaxAutoresponders), "%s", optarg); break; case 'L': snprintf(MaxMailinglists, sizeof(MaxMailinglists), "%s", optarg); break; case 'g': snprintf(GidFlagString, sizeof(GidFlagString), "%s", optarg); GidFlag = 1; break; case 'p': snprintf(PermAccountFlagString, sizeof(PermAccountFlagString), "%s", optarg); PermAccountFlag = 1; break; case 'a': snprintf(PermAliasFlagString, sizeof(PermAliasFlagString), "%s", optarg); PermAliasFlag = 1; break; case 'f': snprintf(PermForwardFlagString, sizeof(PermForwardFlagString), "%s", optarg); PermForwardFlag = 1; break; case 'r': snprintf(PermAutoresponderFlagString, sizeof(PermAutoresponderFlagString), "%s", optarg); PermAutoresponderFlag = 1; break; case 'l': snprintf(PermMaillistFlagString, sizeof(PermMaillistFlagString), "%s", optarg); PermMaillistFlag = 1; break; case 'u': snprintf(PermMaillistUsersFlagString, sizeof(PermMaillistUsersFlagString), "%s", optarg); PermMaillistUsersFlag = 1; break; case 'o': snprintf(PermMaillistModeratorsFlagString, sizeof(PermMaillistModeratorsFlagString), "%s", optarg); PermMaillistModeratorsFlag = 1; break; case 'x': snprintf(PermQuotaFlagString, sizeof(PermQuotaFlagString), "%s", optarg); PermQuotaFlag = 1; break; case 'z': snprintf(PermDefaultQuotaFlagString, sizeof(PermDefaultQuotaFlagString), "%s", optarg); PermDefaultQuotaFlag = 1; break; case 'h': usage(); vexit(0); default: errflag = 1; break; } } if ( optind < argc && EditDefaultLimits == 0) { snprintf(Domain, sizeof(Domain), "%s", argv[optind]); ++optind; } if ( Domain[0] == 0 && EditDefaultLimits == 0) { usage(); vexit(-1); } }
bool BadgeData::setTimetable(TimeTable tt) { #ifdef ONLY_BADGE QFile data; TimeTable dum; qint64 pos = 0; data.setFileName(QDir::homePath() + QDir::separator() + "badge.data"); data.open(QIODevice::ReadWrite); QDataStream out(&data); while (!data.atEnd()) { out >> dum; if (dum.day == tt.day) { data.seek(pos); out << tt; data.close(); return true; } pos = data.pos(); } out << tt; data.close(); return true; #else QSqlQuery query; QVariant vday(tt.day); QVariant venter(tt.entrance); QVariant vexit(tt.exit); QVariant vbeginFirst(tt.firstPause); QVariant vendFirst(tt.endFirstPause); QVariant vbeginSecond(tt.secondPause); QVariant vendSecond(tt.endSecondPause); //QVariant vdefinition (definition); query.prepare("select count(*) from days where daywork = ?"); query.addBindValue(vday); query.exec(); query.next(); if(query.value(0).toInt() > 0) { query.prepare("update days set enter = ? , exit = ? , beginfirst = ? , endfirst = ? , beginsecond = ? , endsecond = ? where daywork = ?"); query.addBindValue(venter); query.addBindValue(vexit); query.addBindValue(vbeginFirst); query.addBindValue(vendFirst); query.addBindValue(vbeginSecond); query.addBindValue(vendSecond); query.addBindValue(vday); if(query.exec()) qDebug() << "UPDATE OK\n"; } else { query.prepare("insert into days values(?,?, ?, ?, ?, ?, ?)"); query.addBindValue(vday); query.addBindValue(venter); query.addBindValue(vexit); query.addBindValue(vbeginFirst); query.addBindValue(vendFirst); query.addBindValue(vbeginSecond); query.addBindValue(vendSecond); query.exec(); } #endif return false; }
/* * Shows various combinations of viewing and * projection transformations. */ main() { char device[20]; fprintf(stderr,"Enter device name: "); gets(device); vinit(device); color(BLACK); clear(); /* * we want to draw just within the boundaries of the screen */ viewport(-0.9, 0.9, -0.9, 0.9); ortho2(-5.0, 5.0, -5.0, 5.0); /* set the world size */ color(RED); rect(-5.0, -5.0, 5.0, 5.0); /* draw a boundary frame */ /* * set up a perspective projection with a field of view of * 40.0 degrees, aspect ratio of 1.0, near clipping plane 0.1, * and the far clipping plane at 1000.0. */ perspective(40.0, 1.0, 0.1, 1000.0); /* * we want the drawing to be done with our eye point at (5.0, 8.0, 5.0) * looking towards (0.0, 0.0, 0.0). The last parameter gives a twist * in degrees around the line of sight, in this case zero. */ lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0); drawtetra(); move2(-4.5, -4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("perspective/lookat"); getkey(); /* * window can also be used to give a perspective projection. Its * arguments are 6 clipping planes, left, right, bottom, top, near, * and far. */ window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); /* * as window replaces the current transformation matrix we must * specify our viewpoint again. */ lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0); color(BLACK); clear(); color(GREEN); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("window/lookat"); getkey(); /* * set up our original perspective projection again. */ perspective(40.0, 1.0, 0.1, 1000.0); /* * polarview also specifies our viewpoint, but, unlike lookat, in polar * coordinates. Its arguments are the distance from the world origin, an * azimuthal angle in the x-y plane measured from the y axis, an * incidence angle in the y-z plane measured from the z axis, and a * twist around the line of sight. */ polarview(15.0, 30.0, 30.0, 30.0); color(BLACK); clear(); color(MAGENTA); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("perspective/polarview"); getkey(); /* * once more with window for comparison */ window(-4.0, 4.0, -4.0, 4.0, -4.0, 4.0); polarview(6.0, 20.0, -30.0, 70.0); color(BLACK); clear(); color(YELLOW); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("window/polarview"); getkey(); vexit(); }