Val _lib7_P_ProcEnv_getgroups (Task* task, Val arg) { //========================= // // Mythryl type: Void -> List(Int) // // Return supplementary group access list ids. // // This fn gets bound as get_group_ids in: // // src/lib/std/src/posix-1003.1b/posix-id.pkg gid gidset[ NGROUPS_MAX ]; Val result; int ngrps = getgroups( NGROUPS_MAX, gidset ); if (ngrps != -1) { // result = mkList (task, ngrps, gidset); } else { gid* gp; // If the error was not due to too small buffer size, // raise exception. // if (errno != EINVAL) return RAISE_SYSERR(task, -1); // Find out how many groups there // are and allocate enough space: // ngrps = getgroups( 0, gidset ); // gp = (gid*) MALLOC( ngrps * (sizeof (gid)) ); // if (gp == 0) { errno = ENOMEM; return RAISE_SYSERR(task, -1); } ngrps = getgroups (ngrps, gp); if (ngrps == -1) result = RAISE_SYSERR(task, -1); else result = mkList (task, ngrps, gp); FREE ((void *)gp); } return result; }
/* parse.c 724b */ Value parsesx(Par p) { switch (p->alt) { case ATOM: { Name n = p->u.atom; const char *s = nametostr(n); long l; /* value of digits in s, if any */ char *t; /* first nondigit in s */ l = strtol(s, &t, 10); if (*t == '\0' && *s != '\0') /* s is all digits */ return mkNum(l); else if (strcmp(s, "#t") == 0) return truev; else if (strcmp(s, "#f") == 0) return falsev; else if (strcmp(s, ".") == 0) error("this interpreter cannot handle . in quoted S-expressions" ); else return mkSym(n); } case LIST: /* parsesx [[LIST]] and return 724c */ if (p->u.list == NULL) return mkNil(); else return mkPair(allocate(parsesx(p->u.list->hd)), allocate(parsesx(mkList(p->u.list->tl)))); } assert(0); return falsev; }
void EmptyDirsFix2::mkList(QDir dir) { QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (int i = 0; i < dirs.size(); i++) { if (isEmpty(QDir(dir.path()+"/"+dirs.at(i)))) { ui->listWidget->addItem(new QListWidgetItem(dir.path()+"/"+dirs.at(i))); } else { mkList(QDir(dir.path()+"/"+dirs.at(i))); } } }
ObjectNode *op_LoadBmp (ExecuteHandler execute, Context *context, Node *node){ void *res = NULL; ObjectNode *objpath = execute(context, &node->childs[0]); char *path = listToString(objpath); BITMAP bmp; if(readBitmap(&bmp, path)) return newObjectNode(NTYPE_NONE, NULL); res = (void *) mkList(&bmp); freeBitmap(&bmp); return res; }
QStringList EmptyDirsFix1::mkList(QDir dir) { QStringList ret; QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (int i = 0; i < dirs.size(); i++) { if (isEmpty(QDir(dir.path()+"/"+dirs.at(i)))) { ret.append(dir.path()+"/"+dirs.at(i)); } else { mkList(QDir(dir.path()+"/"+dirs.at(i))); } } return ret; }
int main(int argc, char *argv[]) { list *l = mkList(); append(l, mkIntCell(1)); append(l, mkIntCell(4)); append(l, mkIntCell(91)); iterator *i = mkIterator(l); int sum = 0; while (hasMore(i)) { sum += *(int*) next(i); } printf("Summa: %d\n", sum); rmIterator(i); rmList(l); return 0; }
void EmptyDirsFix1::next() { QStringList dirs = mkList(QDir(ui->lineFolder->text())); // We don't continue if there were no folders found if (dirs.isEmpty()) { QMessageBox::information(this, tr("Empty folders fixer"), tr("No empty folder found.")); close(); return; } EmptyDirsFix2 *edf2 = new EmptyDirsFix2(dirs); close(); edf2->show(); }
EmptyDirsFix2::EmptyDirsFix2(QString folder, QWidget *parent) : QDialog(parent), ui(new Ui::EmptyDirsFix2), m_folder(folder) { ui->setupUi(this); mkList(QDir(folder)); ui->listWidget->selectAll(); }