Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
Add SteamCmd support
Browse files Browse the repository at this point in the history
  • Loading branch information
fifty-six committed Aug 16, 2021
1 parent 089634a commit 4e887c5
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/main.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const std = @import("std");

const math = std.math;
const process = std.process;
const log = std.log;

const psapi = std.os.windows.psapi;
const win = std.os.windows;
Expand All @@ -22,15 +25,36 @@ pub fn main() !void {
try catch_if_ncli();
}

pub fn usage(exe: []const u8) noreturn {
log.emerg("Usage: {s} [--steamcmd]\n", .{exe});
process.exit(1);
}

pub fn caught_main() !void {
const stdout = std.io.getStdOut().writer();

var heap = std.heap.HeapAllocator.init();
defer heap.deinit();
var gpa = std.heap.GeneralPurposeAllocator(.{}) {};

const allocator = &gpa.allocator;

const allocator = &heap.allocator;
const args = try std.process.argsAlloc(allocator);
defer std.process.argsFree(allocator, args);

var proc_name: [:0]const u8 = "steam.exe";

// One optional param for steamcmd
if (args.len == 2) {
if (std.mem.eql(u8, args[1], "--steamcmd")) {
proc_name = "steamcmd.exe";
} else {
usage(args[0]);
}
// Otherwise, it's just a usage error.
} else if (args.len != 1) {
usage(args[0]);
}

const proc_id = (try proc_id_by_name("steam.exe")) orelse return error.ProcessNotFound;
const proc_id = (try proc_id_by_name(proc_name)) orelse return error.ProcessNotFound;

try stdout.print("Got process handle.\n", .{});

Expand Down

0 comments on commit 4e887c5

Please sign in to comment.